在python中使用networkx中的所有\u pairs\u shortest_path时出现内存错误

2024-06-28 20:17:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我的图有8400多个节点,我想得到所有节点的所有对最短路径。我试着用networkx,它导致内存错误。在

Traceback (most recent call last):
File "C:\Users\Asif\pythonworkspace\Formally\src\lastlast.py", line 19, in <module>
mynewgraph = nx.all_pairs_shortest_path(myGraph)
File "C:\Python27\lib\site-packages\networkx\algorithms\shortest_paths\unweighted.py", line 290, in all_pairs_shortest_path
paths[n]=single_source_shortest_path(G,n,cutoff=cutoff)
File "C:\Python27\lib\site-packages\networkx\algorithms\shortest_paths\unweighted.py", line 254, in single_source_shortest_path
paths[w]=paths[v]+[w]
MemoryError

我刚试过这个mynewgraph=nx.所有连接对最短路径(我的图形)

所有are my节点都有string数据类型,每个边都有一个与之关联的权重。在

请提供您的建议


Tags: pathinpy路径networkx节点lineall