Lecture 6 Shortest Path Problem
s t
Dynamic Programming
Dijkstra’s Algorithm is motivated from a way to implement of this dynamic programming.
Dynamic Programming
Lemma Proof
Theorem
Counterexample
Smart Implementation
An Example Initialize 1 0 Select the node with the minimum temporary distance label.
Update Step 1
Choose u such that N_(u) S
Update Step The predecessor of node 3 is now node 2
Choose u Such That N_(u) S 3
Update d(5) is not changed
Choose u s.t. N_(u) S 5
Update 5 d(4) is not changed 6
Choose u s.t. N_(u) S
Update d(6) is not updated
Choose u s.t. N_(u) S There is nothing to update
End of Algorithm 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
Dijkstra’s Algorithm
Lemma
Proof of Lemma s u w S T
Theorem
Counterexample
Dijkstra’s Algorithm
An Example Initialize 1 0 Select the node with the minimum temporary distance label.
Update Step 1
Choose Minimum Temporary Label
Update Step The predecessor of node 3 is now node 2
Choose Minimum Temporary Label 3
Update d(5) is not changed
Choose Minimum Temporary Label 5
Update 5 d(4) is not changed 6
Choose Minimum Temporary Label
Update d(6) is not updated
Choose Minimum Temporary Label There is nothing to update
End of Algorithm 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
Dijkstra’s Algorithm with simple buckets (also known as Dial’s algorithm)
An Example Initialize distance labels 1 0 Select the node with the minimum temporary distance label Initialize buckets.
Update Step 1
Choose Minimum Temporary Label Find Min by starting at the leftmost bucket and scanning right till there is a non-empty bucket
Update Step
Choose Minimum Temporary Label Find Min by starting at the leftmost bucket and scanning right till there is a non-empty bucket.
Update
Choose Minimum Temporary Label 6 45
Update
Choose Minimum Temporary Label
Update
Choose Minimum Temporary Label There is nothing to update
End of Algorithm 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
Implementations With min-priority queue, Dijkstra algorithm can be implemented in time With Fibonacci heap, Dijkstra algorithm can be implemented in time With Radix heap, Dijkstra algorithm can be implemented in time