1 / 15

An example would be planning a journey to go from Norwich to Manchester

T. 11. A. 3. 4. 5. S. 2. B. 6. D. 1. 4. 4. C. The Shortest Path Problem. Find the shortest path from S to T. An example would be planning a journey to go from Norwich to Manchester. 8. Dijkstra's Algorithm Each vertex is given a label box as shown. Order of

yanka
Download Presentation

An example would be planning a journey to go from Norwich to Manchester

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. T 11 A 3 4 5 S 2 B 6 D 1 4 4 C The Shortest Path Problem Find the shortest path from S to T. An example would be planning a journey to go from Norwich to Manchester 8

  2. Dijkstra's Algorithm Each vertex is given a label box as shown Order of permanent labelling Permanent distance label Temporary distance label

  3. T 11 A 3 4 5 S 2 B 6 D 1 4 4 C • Label start vertex with permanent label 1 • and permanent distance 0.

  4. T 11 A 3 4 5 S 2 B 6 D 1 4 4 C 2. Consider all the edges joining the vertex just labelled i.e. edges joining S to A , B and C. Calculate the sum of the previous permanent distance label plus the distance to the new vertex. This is the temporary distance label.

  5. 8 T 11 A 3 4 5 S 2 B 6 D 1 4 4 C 2 3 Choose the smallest temporary distance label i.e. A and label it with a permanent distance label of 3 and a permanent order label of 2

  6. 8 T 11 A 3 4 5 S 2 B 6 D 1 4 4 C Bigger than 6 so delete 7 3 4 Choose the smallest temporary distance label i.e. C and label it with a permanent distance label of 4 and a permanent order label of 3 Repeat step 2 but this time consider all the vertices connected to A i.e T and B.

  7. 8 T 11 A 3 4 5 S 2 B 6 D 1 4 4 C 4 5 5 3 4 Choose the smallest temporary distance label i.e. B and label it with a permanent distance label of 5 and a permanent order label of 4 Repeat step 2 but this time consider all the vertices connected to C i.e D and B.

  8. T 11 A 3 4 5 2 B 6 D 1 4 4 C 13 8 4 5 S 5 7 5 7 3 4 Choose the smallest temporary distance label i.e. D and label it with a permanent distance label of 7 and a permanent order label of 5 Repeat step 2 but this time consider all the vertices connected to B i.e T and D.

  9. T 11 A 3 4 5 2 B 6 D 1 4 4 C 12 6 13 12 8 4 5 S 5 7 5 7 3 4 Choose the smallest temporary distance label i.e. T and label it with a permanent distance label of 12 and a permanent order label of 6 Repeat step 2 but this time consider all the vertices connected to D i.e T.

  10. 2 3 12 6 3 13 12 14 8 4 5 S 1 0 T 5 6 11 7 5 A 3 4 7 8 5 2 B 3 4 6 4 D 1 4 4 C Find shortest path by working backwards from the finish and choosing only those edges whose length is exactly equal to the difference between the permanent distance labels at either end.

  11. 2 3 12 6 3 13 12 14 8 4 5 S 1 0 T 5 6 11 7 5 A 3 4 7 8 5 2 B 3 4 6 4 D 1 4 4 C From T 12 - 5 = 7 ie vertex D . This is the vertex to choose From T 12 - 8  5 so cannot choose B From T 12 - 11  3 so cannot choose A

  12. 2 3 12 6 3 13 12 14 8 4 5 S 1 0 T 5 6 11 7 5 A 3 4 7 8 5 2 B 3 4 6 4 D 1 4 4 C From D 7 - 2 = 5 ie vertex B . This is the vertex to choose From D 7- 4  4 so cannot choose C

  13. 2 3 12 6 3 13 12 14 8 4 5 S 1 0 T 5 6 11 7 5 A 3 4 7 8 5 2 B 3 4 6 4 D 1 4 4 C From B 5 - 1 = 4 ie vertex C . This is the vertex to choose From B 5 - 4  3 so cannot choose AFrom B 5 - 6  0 so cannot choose S

  14. 2 3 12 6 3 13 12 14 8 4 5 S 1 0 T 5 6 11 7 5 A 3 4 7 8 5 2 B 3 4 6 4 D 1 4 4 C From C 4 - 4 = 0 ie vertex S . This is the vertex to choose

  15. 2 3 12 6 3 13 12 14 8 4 5 S 1 0 T 5 6 11 7 5 A 3 4 7 8 5 2 B 3 4 6 4 D 1 4 4 C Route T,D,B,C,S. So starting from S the route is S,C,B,D,T and the distance is 12

More Related