NetworkX全最短路径算法和scipy floyd warshall算法有什么区别?有什么理由比另一个更喜欢一个吗?哪个最快?
最佳答案
(对于那些不知道 numpy floyd-warshall 算法在 networkx 中可用的人)
网络x description floyd_warshall_numpy 状态:
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).
networkx single_source_shortest_path 在稀疏图上效果更好。您应该知道,如果您使用各种“最短路径”算法,这些算法会忽略边权重。各种 Dijkstra 算法包含边权重。
还有更多描述here .
关于python - NetworkX vs Scipy 所有最短路径算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23463713/