17-Shortest-Paths-I

17-Shortest-Paths-I - Algorithms L17.1 Algorithms Professor...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 Breadth-first search Algorithms L17.2 Paths in graphs Consider a digraph G = ( V , E ) with edge-weight 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 edge-weight 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 Well-definedness of shortest paths If a graph G contains a negative-weight cycle, then some shortest paths may not exist. Algorithms L17.11 Well-definedness of shortest paths If a graph G contains a negative-weight cycle, then some shortest paths may not exist. Example: u v < 0 Algorithms L17.12 Single-source shortest paths Problem. From a given source vertex s V , find the shortest-path weights ( s , v ) for all v V . If all edge weights w ( u , v ) are nonnegative , all shortest-path 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 XTRACT-M 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

Page1 / 59

17-Shortest-Paths-I - Algorithms L17.1 Algorithms Professor...

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

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