Dijkstra AIgorithm: Finding
shortest paths in order
.
.
.
.
Closest node to . is 1 hop away
.
_
_
2
nd
closest node to . is 1 hop
away from . or ."
_
:
:
3rd closest node to . is 1 hop
away from ., .", or _
.
Find shortest paths from
source s to all other
destinations
Dijkstra's aIgorithm
N set of nodes for which shortest path already found
nitialization (Start with source node s)
N = {s}, D
s
0, "s is distance zero from itself
D
j
=C
sj
for all j s, distances of directly-connected neighbors
Step A (ind next closest node i
Find i [ N such that
D
i
min Dj for j [ N
Add i to N
f N contains all the nodes, stop
Step B (update minimum costs)
For each node j [ N
D
j
min (D
j
, D
i
+C
ij
o to Step A
inimum distance from s to
j through node in N
ecution of Dijkstra's aIgorithm
teration N D
2
D
3
D
4
D
5
D
6
nitial {1} 3 2 5 M M
1 {1,3} 3 4 M 3
2 {1,2,3} 4 7 3
3 {1,2,3,6} 4 5
4 {1,2,3,4,6} 5
5 {1,2,3,4,5,6}
$hortest Paths in Dijkstra's
AIgorithm