如何在python中将文件从gml转换为edgelist?

时间:2014-06-15 11:33:43

标签: python python-2.7 networkx

python中是否有任何示例,如何将文件从* .gml转换为* .edgelist? 谢谢

1 个答案:

答案 0 :(得分:4)

In [1]:  import networkx as nx

In [2]:  g = nx.read_gml('gmlFile.gml')

In [3]:  nx.write_edgelist(g, 'edgelistFile.csv', delimiter=',')

<强>文档

read_gml(path, encoding='UTF-8', relabel=False)

write_edgelist(G, path, comments='#', delimiter=' ', data=True, encoding='utf-8')[source]