1 / 14

Shortest Path Algorithm

Shortest Path Algorithm. By Weston Vu CS 146. What is Shortest Paths?. Shortest Paths is a part of the graph algorithm. It is used to calculate the shortest way from the starting point to the destination by adding the weight of the edges together. Shortest Path.

roch
Télécharger la présentation

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 By Weston Vu CS 146

  2. What is Shortest Paths? Shortest Paths is a part of the graph algorithm. It is used to calculate the shortest way from the starting point to the destination by adding the weight of the edges together.

  3. Shortest Path • There are 2 types of shortest path: • Weight shortest path • Unweight shortest path: assign all edges a weight of 1 V1 V2 V4 V5 V3 V7 V6

  4. UnWeight Shortest Path V1 V2 dw = dv + 1 if dw = ¥ V4 V5 V3 V7 V6

  5. UnWeight Shortest Path V1 V2 V4 V5 V3 V7 V6

  6. UnWeight Shortest Path V1 V2 V4 V5 V3 V7 V6

  7. UnWeight Shortest Path V1 V2 V4 V5 V3 V7 V6

  8. Dijkstra’s AlgorithmWeight Shortest Path 2 V1 V2 dw = dv + cv,w if new value for dw would be an improve 10 4 1 3 2 2 V4 V5 V3 8 4 6 5 1 V7 V6

  9. Dijkstra’s AlgorithmWeight Shortest Path 2 V1 V2 10 4 1 3 2 2 V4 V5 V3 8 4 6 5 1 V7 V6

  10. Dijkstra’s AlgorithmWeight Shortest Path

  11. Dijkstra’s AlgorithmWeight Shortest Path 2 V1 V2 10 4 1 3 2 2 V4 V5 V3 8 4 6 5 1 V7 V6

  12. Graphs with Negative Edge Cost • If the graph has negative edge costs, then it makes the problem harder • If negative-cost cycle are present, then the algorithm will loop indefinitely V1 V2 2 -10 4 1 3 2 2 V4 V5 V3 8 4 6 5 1 V7 V6

  13. Acyclic Graph • Changing the order in which vertices are declared known • Set the vertices in topological order C-3 A-3 F-3 Finish Start D-2 G-2 B-2 E-1

  14. The END

More Related