NetworkX vs Scipy all shortest path algorithms

ぃ、小莉子 提交于 2019-12-07 09:21:20

问题


What are the differences between the NetworkX all shortest paths algorithm and the scipy floyd warshall algorithm? Are there any reasons to prefer one over another? Which is fastest?


回答1:


(for those who aren't aware the numpy floyd-warshall algorithm is available in networkx)

The networkx description of floyd_warshall_numpy states:

Floyd’s algorithm is appropriate for finding shortest paths in dense graphs or graphs with negative weights when Dijkstra’s algorithm fails. This algorithm can still fail if there are negative cycles. It has running time O(n^3) with running space of O(n^2).

The networkx single_source_shortest_path works better on sparse graphs. You should be aware that if you use the various "shortest_path" algorithms, these ignore edge weights. The various Dijkstra algorithms incorporate edge weights.

There is more description here.



来源:https://stackoverflow.com/questions/23463713/networkx-vs-scipy-all-shortest-path-algorithms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!