我正在尝试使用networkX自定义图形(用于gexf格式)。但我无法设置节点的形状。 使用示例here
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'
我错过了什么吗?