Shortest Path Algorithm This is called Dijkstras Algorithm

  • Slides: 7
Download presentation
Shortest Path Algorithm This is called “Dijkstra’s Algorithm” …pronounced “Dirk-stra”

Shortest Path Algorithm This is called “Dijkstra’s Algorithm” …pronounced “Dirk-stra”

Problem: Find the shortest route from A to F

Problem: Find the shortest route from A to F

Step 1 Label the start vertex S with a permanent label of 0 Step

Step 1 Label the start vertex S with a permanent label of 0 Step 2 Put 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.

Step 3 Select the minimum temporary label and make it permanent. Step 4 Repeat

Step 3 Select the minimum temporary label and make it permanent. Step 4 Repeat steps 2 and 3 until the destination vertex T receives its permanent label. Step 5 Trace back from T to S including an arc AB whenever the permanent label of B permanent label of A = the weight of AB, given that B already lies on the path.

Each vertex will have a box like the one below which has to be

Each vertex will have a box like the one below which has to be filled in: Vertex Order Final Letter of Values Select ion Working Values

Problem: Find the shortest route from A to F On the exam paper your

Problem: Find the shortest route from A to F On the exam paper your diagram will look like this:

15 B 3 7 but 15 > 13 so ignore D 8 7 5

15 B 3 7 but 15 > 13 so ignore D 8 7 5 13 16 – 13 = 3 so use DF Now trace back from FSixth First vertex Second Third Fourth Fifth vertex is is isis A is D B FEC 13 – 9 = 4 so use CD 7 Label 16 04 – 0 = 4 so use AC 4 7 12 13 A 1 13 3 0 F 6 17 16 Shortest Path is ACDF of length 16 4 Temporary Labels 5 5 9 C 4 2 4 9 E 4 13 12 12 16