- Dijkstra’s Algorithm is one example of a single-source shortest or SSSP algorithm, i.e., given a source vertex it finds shortest path from source to all other vertices.
- Floyd Warshall Algorithm is an example of all-pairs shortest path algorithm, meaning it computes the shortest path between all pair of nodes.
Time Complexities :
- Time Complexity of Dijkstra’s Algorithm: O(E log V)
- Time Complexity of Floyd Warshall: O(V3)
- We can use Dijskstra’s shortest path algorithm for finding all pair shortest paths by running it for every vertex. But time complexity of this would be O(VE Log V) which can go (V3 Log V) in worst case.
- Another important differentiating factor between the algorithms is their working towards distributed systems. Unlike Dijkstra’s algorithm, Floyd Warshall can be implemented in a distributed system, making it suitable for data structures such as Graph of Graphs (Used in Maps).
- Lastly Floyd Warshall works for negative edge but no negative cycle, whereas Dijkstra’s algorithm don’t work for negative edges.
This article is contributed by Vineet Joshi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Maximum number of nodes which can be reached from each node in a graph.
- Number of trees whose sum of degrees of all the vertices is L
- Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes
- Count the nodes of a tree whose weighted string is an anagram of the given string
- Count the nodes of a tree whose weighted string does not contain any duplicate characters
- Print the degree of every node from the given Prufer sequence
- Print the node with the maximum degree in the prufer sequence
- Count the nodes of the given tree whose weight has X as a factor
- Count the nodes of the given tree whose weighted string is a palindrome
- Count the nodes in the given tree whose sum of digits of weight is odd
- Count the nodes in the given tree whose weight is even parity
- Count the nodes in the given tree whose weight is a power of two
- Find the root of the sub-tree whose weighted sum is minimum
- Minimum number of pairs required to make two strings same