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 There are 2 types of shortest path: –Weight shortest path –Unweight shortest path: assign all edges a weight of 1 V1V2 V5 V3 V4 V6 V7
UnWeight Shortest Path V1V2 V5 V3 V4 V6 V7 d w = d v + 1 if d w =
UnWeight Shortest Path V1V2 V5 V3 V4 V6 V7
UnWeight Shortest Path V1V2 V5V4 V6 V7 V3
UnWeight Shortest Path V1V2 V5V4 V6 V7 V3
Dijkstra’s Algorithm Weight Shortest Path V1V2 V5 V3 V4 V6 V d w = d v + c v,w if new value for d w would be an improve
Dijkstra’s Algorithm Weight Shortest Path V1V2 V5 V3 V4 V6 V
Dijkstra’s Algorithm Weight Shortest Path
V1V2 V5 V3 V4 V6 V
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 V1V2 V5 V3 V4 V6 V
Acyclic Graph Changing the order in which vertices are declared known Set the vertices in topological order Start A-3 B-2 D-2 C-3 E-1 F-3 G-2 Finish
The END