1 / 7

Shortest Path Algorithm

Shortest Path Algorithm. This is called “Dijkstra’s Algorithm”. …pronounced “Dirk-stra”. Problem:. Find the shortest route from A to F. Step 1 Label the start vertex S with a permanent label of 0.

yon
Download Presentation

Shortest Path Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 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.

  4. 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.

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

More Related