【问题标题】:change graph attributes in python在python中更改图形属性
【发布时间】:2020-08-15 13:01:38
【问题描述】:

我无法更改igraph 中图形对象中特定顶点的属性。

from igraph import *
G = Graph()
G.add_vertices(2)
G.vs['names'] = [(1, 1), (10, 10)]

# change the name
G.vs['names'][0] = (5, 5)
print G.vs['names'][0]
(1, 1)

我尝试将元组更改为列表,但没有成功

G = Graph()
G.add_vertices(2)
G.vs['names'] = [ [1, 1], [10, 10] ]
G.vs['names'][0] = [5, 5]
print G.vs['names'][0]
[1, 1]

我也尝试使用G.vs['position'][0].pop(),但它也不起作用。知道如何更改 igraph 中的属性吗?

【问题讨论】:

    标签: python-3.x igraph


    【解决方案1】:

    问题似乎是我正在使用:

    G.vs["position"][0] = [5, 5]
    

    我需要改用这个:

    G.vs[0]["position"] = [5, 5]
    

    这解决了它,谢谢!

    【讨论】:

      猜你喜欢
      • 2012-03-08
      • 2012-11-17
      • 1970-01-01
      • 2017-09-07
      • 1970-01-01
      • 2020-09-27
      • 1970-01-01
      • 2012-05-28
      • 1970-01-01
      相关资源
      最近更新 更多