Idea of Dijkstra’s Algorithm:
Maintain:
- Dist [0..n-1] where Dist (v) is the cost of best path from s to v found so far, and
- U, set of vertices v for which Dist (v) is not yet known to be optimal.
Initially:
- Dist (s) = 0; Dist (v) = infinity for all v other than s.
- U = V.
In each step, remove that v in U with minimum Dist(v)
update those w in U s.t. (v,w) in E and
Dist(w) > Dist(w) + c(v,w).