This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Shortest Paths 1 Shortest Paths C B A E D F 3 2 8 5 8 4 8 7 1 2 5 2 3 9 Shortest Paths 2 Outline and Reading Weighted graphs (12.1) Shortest path problem Shortest path properties Dijkstras algorithm (12.6.1) Algorithm Edge relaxation The BellmanFord algorithm Shortest paths in DAGs Allpairs shortest paths Shortest Paths 3 Weighted Graphs In a weighted graph, each edge has an associated numerical value, called the weight of the edge Edge weights may represent, distances, costs, etc. Example: In a flight route graph, the weight of an edge represents the distance in miles between the endpoint airports ORD PVD MIA DFW SFO LAX LGA HNL 849 8 2 1 3 8 7 1 7 4 3 1843 1 9 9 1120 1233 3 3 7 2555 1 4 2 1 2 5 Shortest Paths 4 Shortest Path Problem Given a weighted graph and two vertices u and v , we want to find a path of minimum total weight between u and v. Length of a path is the sum of the weights of its edges. Example: Shortest path between Providence and Honolulu Applications Internet packet routing Flight reservations Driving directions ORD PVD MIA DFW SFO LAX LGA HNL 849 8 2 1 3 8 7 1 7 4 3 1843 1 9 9 1120 1233 3 3 7 2555 1 4 2 1 2 5 Shortest Paths 5 Shortest Path Properties Property 1: A subpath of a shortest path is itself a shortest path Property 2: There is a tree of shortest paths from a start vertex to all the other vertices Example: Tree of shortest paths from Providence ORD PVD MIA DFW SFO LAX LGA HNL 849 8 2 1 3 8 7 1 7 4 3 1843 1 9 9 1120 1233 3 3 7 2555 1 4 2 1 2 5 Shortest Paths 6 Dijkstras Algorithm The distance of a vertex v from a vertex s is the length of a shortest path between s and v Dijkstras algorithm computes the distances of all the vertices from a given start vertex s Assumptions: the graph is connected the edges are undirected the edge weights are nonnegative We grow a cloud of vertices, beginning with s and eventually covering all the vertices We store with each vertex v a label d ( v ) representing the distance of v from s in the subgraph consisting of the cloud...
View
Full
Document
 Fall '08
 Staff
 Data Structures

Click to edit the document details