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中有numpy-floyd-warshall算法的用户)
floyd\u warshall\u numpy的网络X description声明:
networkx单源最短路径在稀疏图上效果更好。你应该意识到这些最短路径的权值,你应该忽略这些算法。各种Dijkstra算法都包含了边缘权重。在
还有更多的描述here。在
相关问题 更多 >
编程相关推荐