Download presentation
Presentation is loading. Please wait.
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 V1V2 V5 V3 V4 V6 V7
4
UnWeight Shortest Path V1V2 V5 V3 V4 V6 V7 d w = d v + 1 if d w =
5
UnWeight Shortest Path V1V2 V5 V3 V4 V6 V7
6
UnWeight Shortest Path V1V2 V5V4 V6 V7 V3
7
UnWeight Shortest Path V1V2 V5V4 V6 V7 V3
8
Dijkstra’s Algorithm Weight Shortest Path V1V2 V5 V3 V4 V6 V7 2 41 3 10 22 5 8 1 46 d w = d v + c v,w if new value for d w would be an improve
9
Dijkstra’s Algorithm Weight Shortest Path V1V2 V5 V3 V4 V6 V7 2 41 3 10 22 5 8 1 46
10
Dijkstra’s Algorithm Weight Shortest Path
11
V1V2 V5 V3 V4 V6 V7 2 41 3 10 22 5 8 1 46
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 V1V2 V5 V3 V4 V6 V7 41 3 -10 22 5 8 1 46 2
13
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
14
The END
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.