更改python中的图形属性

问题描述 投票:0回答:1

我在更改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个回答
0
投票

似乎问题出在我正在使用:

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

而且我需要改用它:

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

此问题已解决,谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.