graphs3-handouts

graphs3-handouts - ECE 537 Foundations of Computing Module...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 537 – Foundations of Computing Module 8, Lecture 3: Graph Algorithms – Shortest Paths Algorithms Professor G.L. Heileman University of New Mexico Fall 2008 c ± 2008 G. L. Heileman Module 8, Lecture 3
Background image of page 1

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

View Full DocumentRight Arrow Icon
Shortest Paths We have already seen that breadth-first search can be used to solve the single-source shortest-paths problem for unweighted graphs, but for weighted graphs this problem is more difficult. In a weighted graph, a shortest path p from vertex s to vertex d is defined as a path s p d whose total edge weight: w ( p ) = X ( u , v ) p w ( u , v ) is minimal. If d is not reachable from s , then the shortest path from s to d is defined to be . c ± 2008 G. L. Heileman Module 8, Lecture 3
Background image of page 2
Shortest Paths—Optimal Substructure Optimal substructure in this problem: The subpaths of shortest paths must themselves be shortest paths. Statement: Given a weighted directed graph G = ( V , E ), with weight function w : E → < , if p = < v 1 , v 2 , . . . , v k > is a shortest path from v 1 to v k , then for any i and j , 1 i j k , subpath p ij = < v i , v i +1 , . . . , v j > is a shortest path from v i to v j . Proof: Consider the following decomposition of the shortest path p : v 1 p 1 i v i p ij v j p jk v k which has weight w ( p ) = w ( p 1 i ) + w ( p ij ) + w ( p jk ). Now assume that some p ij is not the shortest path from v i to v j , i.e., that p 0 ij is a shorter path. Then, v 1 p 1 i v i p 0 ij v j p jk v k is also a path from v 1 to v k that has total weight less than w ( p ). This contradicts the optimality of path p , and establishes that the subproblems p ij , 1 i j k , must be optimal. c ± 2008 G. L. Heileman Module 8, Lecture 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
The presence of negative-weight edges can cause difficulties when attempting to solve shortest path problems. If a graph contains negative-weight edges, the shortest path is only defined if there are no negative-weight cycles reachable from the source vertex. Consider the following graph: v 3 4 v 1 v 2 v v 5 3 4 3 2 2 -6 The total edge weight along cycle v 3 , v 4 , v 5 , v 3 is - 1. Since this cycle is reachable from any vertex in the graph, the shortest path between any pair of vertices in this graph is not defined. Negative-weight edges are not the problem. If edge ( v 3 , v 4 ) is - 5 instead of - 6, the shortest path between any pair of vertices in the graph becomes well-defined. c
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

graphs3-handouts - ECE 537 Foundations of Computing Module...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online