Download presentation
Presentation is loading. Please wait.
Published byPolly Davidson Modified over 9 years ago
1
Shortest Path Algorithms
2
Definitions
5
Variants Single-source shortest-paths problem: Given a graph, finding a shortest path from a given source vertex to all the vertices in the graph (Our problem) Single-destination shortest-paths problem: If you reverse the directions of all edges, you can solve it as a single-source problem.
6
Variants
7
All-pairs shortest-path problems: Find a shortest part from each vertex to each vertex. Although this problem can be solved by running a single-source algorithm once from each vertex, it can usually be solved faster.
8
Structure of a Shortest Path Subpaths of shortest paths are shortest paths. (WHY?) Negative-weight edges? Cycles? Negative-weight cycles?
9
Representing Shortest Paths
10
Initialization
11
Relaxation
13
The Bellman-Ford Algorithm The Bellman-Ford Algorithm solves the single- source shortest-path problems in which the edge weights may be negative. It also alerts us if there is a negative-weight cycle that is reachable from the source. If there is no such cycle, the algorithm produces the shortest paths and their weights.
15
Example and Implementation Issues
16
Correctness
17
Computational Complexity
18
Dijkstra’s Algorithm
21
Example
22
Implementation Issues
23
Approach
24
Correctness
25
Proof:
26
Computational Complexity
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.