This preview shows pages 1–16. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Algorithms L17.1 Algorithms Professor Ashok Subramanian L ECTURE 17 Shortest Paths I Properties of shortest paths Dijkstras algorithm Correctness Analysis Breadthfirst search Algorithms L17.2 Paths in graphs Consider a digraph G = ( V , E ) with edgeweight function w : E R . The weight of path p = v  = + = 1 1 1 ) , ( ) ( k i i i v v w p w . Algorithms L17.3 Paths in graphs Consider a digraph G = ( V , E ) with edgeweight function w : E R . The weight of path p = v  = + = 1 1 1 ) , ( ) ( k i i i v v w p w . v v v v v 4 2 5 1 Example: w ( p ) = 2 Algorithms L17.4 Shortest paths A shortest path from u to v is a path of minimum weight from u to v . The shortest path weight from u to v is defined as ( u , v ) = min{ w ( p ) : p is a path from u to v } . Note: ( u , v ) = if no path from u to v exists. Algorithms L17.5 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Algorithms L17.6 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Proof. Cut and paste: Algorithms L17.7 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Proof. Cut and paste: Algorithms L17.8 Triangle inequality Theorem. For all u , v , x V , we have ( u , v ) ( u , x ) + ( x , v ) . Algorithms L17.9 Triangle inequality Theorem. For all u , v , x V , we have ( u , v ) ( u , x ) + ( x , v ) . u Proof. x v ( u , v ) ( u , x ) ( x , v ) Algorithms L17.10 Welldefinedness of shortest paths If a graph G contains a negativeweight cycle, then some shortest paths may not exist. Algorithms L17.11 Welldefinedness of shortest paths If a graph G contains a negativeweight cycle, then some shortest paths may not exist. Example: u v < 0 Algorithms L17.12 Singlesource shortest paths Problem. From a given source vertex s V , find the shortestpath weights ( s , v ) for all v V . If all edge weights w ( u , v ) are nonnegative , all shortestpath weights must exist. I DEA : Greedy. 1. Maintain a set S of vertices whose shortest path distances from s are known. 2. At each step add to S the vertex v V S whose distance estimate from s is minimal. 3. Update the distance estimates of vertices adjacent to v . Algorithms L17.13 Dijkstras algorithm d [ s ] for each v V { s } do d [ v ] S Q V Q is a priority queue maintaining V S Algorithms L17.14 Dijkstras algorithm d [ s ] for each v V { s } do d [ v ] S Q V Q is a priority queue maintaining V S while Q do u E XTRACTM IN ( Q ) S S { u } for each v Adj [ u ] do if d [ v ] > d [ u ] + w ( u , v ) then d [ v ] d [ u ] + w ( u , v ) Algorithms L17.15 Dijkstras algorithm...
View Full
Document
 Spring '11
 k.v.arya
 Algorithms

Click to edit the document details