855J
Dijkstras Algorithm
An Example
2 4
4 2 3 2
0
1
2 1 4 3 3 5 2
Initialize Select the node with the minimum temporary distance label.
Update Step
2
2 4
4 2 3 2
0
1
2 1 4 3 3 5 2
4 2 3 2
0
1
2 1 4 3 3 5 2
Update Step
2
2 4
6
4 2 3 2
0
1
2 1 4 3 3 5 2
6
4 2 3 2
0
1
2 1 4 3 3 5 2
Update
2
2 4
6
4 2 3 2
0
1
2 1 4 3 3 5 2
6
4 2 3 2
0
1
2 1 4 3 3 5 2
Update
2
2 4
6
4 2 3 2
0
1
2 1 4 3 3 5 2
6
4 2 3 2
0
1
2 1 4 3 3 5 2
10
Update
2
2 4
6
4 2 3 2
0
1
2 1 4 3 3 5 2
11
6
4 2 3 2
0
1
2 1 4 3 3 5 2
End of Algorithm
2
2 4
6
4 2 3 2
0
1
2 1 4 3 3 5 2
All nodes are now permanent The predecessors form a tree The shortest path from node 1 to node 6 can be found by tracing back predecessors
13