python - NetworkX vs Scipy 所有最短路径算法

标签 python scipy networkx shortest-path

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/

相关文章:

python - scipy.io.wavfile.read 无法读取 24 位 .wav 文件

python - 绘制嵌套的 networkx 图

python - 为什么在Python类的__init__中使用self.foo = self.foo?

python - 如何从 tsv 文件中找到所有节点三元组(大小为 3 的连通分量)?

Python BeautifulSoup - 在解析无效 HTML 时使用 find_next

Python 如何从Basic Table获取Scrapy Xpath数据?

python - 正确执行 fftshift 和 ifftshift 的顺序(在 python 中)

python - 使用 find_peaks_cwt 在噪声数据中查找峰值

python - 如何抓取网络新闻并将段落合并到每篇文章中

python - 如何用py2exe更正TCL_LIBRARY和TK_LIBRARY