Download presentation
Presentation is loading. Please wait.
Published byBrenda Watkins Modified over 9 years ago
1
Shortest Path Algorithm This is called “Dijkstra’s Algorithm” …pronounced “Dirk-stra”
2
Problem: Find the shortest route from A to F
3
Step 1Label the start vertex S with a permanent label of 0 Step 2Put a temporary label on each vertex that can be reached directly from the vertex that has just received a permanent label. The temporary label must be equal to the sum of the permanent label and the weight of the arc linking it directly to the vertex. If there is already a temporary label at the vertex, it is only replaced if the new sum is smaller.
4
Step 3Select the minimum temporary label and make it permanent. Step 4Repeat steps 2 and 3 until the destination vertex T receives its permanent label. Step 5Trace back from T to S including an arc ABwhenever the permanent label of B permanent label of A = the weight of AB, given that B already lies on the path.
5
Vertex Letter Order of Selection Final Values Working Values Each vertex will have a box like the one below which has to be filled in:
6
Problem: Find the shortest route from A to F On the exam paper your diagram will look like this:
7
8 7 3 4 5 9 9 5 A B C D E F First vertex is A 1 Label 0 0 Temporary Labels 7 4 Second vertex is C 2 Label 4 4 13 Third vertex is B 3 Label 7 7 15 but 15 > 13 so ignore Fourth vertex is E 4 Label 12 12 17 Fifth vertex is D 5 Label 13 13 16 6 Sixth vertex is F Label 16 16 Now trace back from F 16 – 13 = 3 so use DF 13 – 9 = 4 so use CD 4 – 0 = 4 so use AC Shortest Path is ACDF of length 16
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.