具有下列问题networkx图形转换成graphml(不能在这里发布的所有代码,但这里的要点)。 NetworkX版本是1.6.2
我有一个称为图G networkx有向图
G = nx.DiGraph()
与来自作者的列表格式加权边缘填充它(作者单位,AuthorB,重量)
G.add_weighted_edges_from(author_list)
我在这里可以导出graphml和正常工作
nx.write_graphml(G, 'test.graphml')
然后,我计算出的曲线图中的PageRank
graph_metric = nx.pagerank_numpy(G, weight='weight')
然后将属性添加到节点图中的
nx.set_node_attributes(G, 'pagerank', graph_metric)
如果我遍历图我可以打印出节点名称和歌的PageRank
for n.d in G.nodes_iter(data=True):
print n, d
{作者单位u'pagerank':0.0076688948270074164} ... ... ...
但是,如果更新后的属性我尝试创建从图中我得到了以下错误graphml:
File "/usr/lib/pymodules/python2.7/networkx/readwrite/graphml.py", line 111, in generate_graphml
writer.add_graph_element(G)
File "/usr/lib/pymodules/python2.7/networkx/readwrite/graphml.py", line 305, in add_graph_element
self.add_nodes(G,graph_element)
File "/usr/lib/pymodules/python2.7/networkx/readwrite/graphml.py", line 262, in add_nodes
self.add_attributes("node", node_element, data, default)
File "/usr/lib/pymodules/python2.7/networkx/readwrite/graphml.py", line 255, in add_attributes
scope=scope, default=default_value)
File "/usr/lib/pymodules/python2.7/networkx/readwrite/graphml.py", line 242, in add_data
raise nx.NetworkXError('GraphML writer does not support '
NetworkXError: GraphML writer does not support dict types as data values.
思考?