我有一个gml
个文件(~20mb),有90.000个节点和200.000个边。对于每个节点,有一个id
和label
,它是12个字符的字符串。我想用networkx
打开此图表但返回:
Traceback (most recent call last):
File "myfile.py", line 166, in <module>
G = nx.read_gml('mygraph.gml', relabel = True)
File "<string>", line 2, in read_gml
File "C:\Python27\lib\site-packages\networkx\utils\decorators.py", line 263, i
n _open_file
result = func(*new_args, **kwargs)
File "C:\Python27\lib\site-packages\networkx\readwrite\gml.py", line 85, in re
ad_gml
G=parse_gml(lines,relabel=relabel)
File "C:\Python27\lib\site-packages\networkx\readwrite\gml.py", line 173, in p
arse_gml
G.add_edge(source,target,attr_dict=vdict)
File "C:\Python27\lib\site-packages\networkx\classes\multigraph.py", line 261,
in add_edge
keydict={key:datadict}
MemoryError
这是因为这些内存不多吗?你能不能请某人提出建议?
答案 0 :(得分:0)
试试read_gml('mygraph.gml', relabel = False)
。如果再次出现内存错误,那么您将确保networkx.read_gml
函数不能应用于超过90.000个节点和200.000个边缘的GML文件。
替代方案可以graph-tool,尝试。