我正在尝试使用networkX(以gexf格式使用)自定义图形。但是我无法设置节点的形状。在这里使用示例
import sys
import urllib2
import networkx as nx
data = urllib2.urlopen('http://gexf.net/data/viz.gexf')
G = nx.read_gexf(data)
print G.node['a']
G.node['a']['viz']['position']['x']=10
G.node['a']['viz']['position']['y']=20
# now my addition
G.node['a']["viz"]['shape'] = 'disc'
print G.node['a'] this seems to work
但我不能写文件
nx.write_gexf(G,sys.stdout)
错误是:
# AttributeError: 'str' object has no attribute 'get'
我想念什么吗?
相关分类