ShortestPath-handouts-2

# ShortestPath-handouts-2 - Shortest Path 2:42 PM Shortest...

This preview shows pages 1–4. Sign up to view the full content.

Shortest Path 4/3/2006 2:42 PM 1 Shortest Paths 1 Shortest Paths C B A E D F 0 3 2 8 58 4 8 7 1 2 5 2 3 9 Shortest Paths 2 Outline and Reading Weighted graphs (§7.1) ± Shortest path problem ± Shortest path properties Dijkstra’s algorithm (§7.1.1) ± Algorithm ± Edge relaxation The Bellman-Ford algorithm (§7.1.2) Shortest paths in dags (§7.1.3) All-pairs shortest paths (§7.2.1)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Shortest Path 4/3/2006 2:42 PM 2 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 0 2 1 3 87 17 4 9 1120 7 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
Shortest Path 4/3/2006 2:42 PM 3 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 0 2 1 3 87 7 4 9 1120 5 Shortest Paths 6 Dijkstra’s Algorithm The distance of a vertex v from a vertex s is the length of a shortest path between s and v Dijkstra’s 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 and its adjacent vertices At each step ± We add to the cloud the vertex u outside the cloud with the

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

ShortestPath-handouts-2 - Shortest Path 2:42 PM Shortest...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online