python networkx进行最短路径分析_NetworkX vs Scipy所有最短路径算法
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?
解決方案
(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.
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的python networkx进行最短路径分析_NetworkX vs Scipy所有最短路径算法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux 重定向_Unix/Linux
- 下一篇: python dataframe取列名_