Dijkstra and Warshall
Dijkstra and Warshall
many single-source shortest path problems having non-negative edge weight in the graphs i.e.,
it is to find the shortest distance between two vertices on a graph. It was conceived by
Dutch computer scientist Edsger W. Dijkstra in 1956.
In a directed graph, each edge has a direction, indicating the direction of travel
between the vertices connected by the edge. In this case, the algorithm follows the
direction of the edges when searching for the shortest path.
In an undirected graph, the edges have no direction, and the algorithm can traverse
both forward and backward along the edges when searching for the shortest path.
The algorithm will generate the shortest path from node 0 to all the other nodes in the
graph.
For this graph, we will assume that the weight of the edges represents the distance
between two nodes.
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 ->
= 2 + 5 + 10 = 17 Node 6 = 2 + 5 + 10 + 2 = 19
Time With a priority queue or min-heap, time The time complexity of the Floyd-
Complexity complexity is O(E + V*log(V)). Warshall algorithm is O(V^3).