The best shortest path algorithm

前端 未结 6 864
傲寒
傲寒 2020-12-01 04:02

What is the difference between the \"Floyd-Warshall algorithm\" and \"Dijkstra\'s Algorithm\", and which is the best for finding the shorte

6条回答
  •  抹茶落季
    2020-12-01 04:34

    Use the Floyd-Warshall algorithm if you want to find the shortest path between all pairs of vertexes, as it has a (far) higher running time than Dijkstra's algorithm.

    The Floyd-Warshall algorithm has a worst case performance of O(|V|3), where as Dijkstra's has a worse case performance of O(|E| + |V|log |V|)

提交回复
热议问题