lec17 - Introduction to Algorithms 6.046J/18.401J LECTURE...

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

View Full Document Right Arrow Icon
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L17.1 Introduction to Algorithms 6.046J/18.401J L ECTURE 17 Shortest Paths I Properties of shortest paths Dijkstra’s algorithm Correctness Analysis Breadth-first search Prof. Erik Demaine
Background image of page 1

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

View Full DocumentRight Arrow Icon
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson 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 v 2 L v k is defined to be = + = 1 1 1 ) , ( ) ( k i i i v v w p w .
Background image of page 2
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson 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 v 2 L v k is defined to be = + = 1 1 1 ) , ( ) ( k i i i v v w p w . v 1 v 1 v 2 v 2 v 3 v 3 v 4 v 4 v 5 v 5 4– 2 51 Example: w ( p ) = –2
Background image of page 3

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

View Full DocumentRight Arrow Icon
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson 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.
Background image of page 4
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L17.5 Optimal substructure Theorem. A subpath of a shortest path is a shortest path.
Background image of page 5

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

View Full DocumentRight Arrow Icon
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L17.6 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Proof. Cut and paste:
Background image of page 6
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L17.7 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Proof. Cut and paste:
Background image of page 7

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

View Full DocumentRight Arrow Icon
November 14, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L17.8 Triangle inequality Theorem. For all u , v , x V , we have δ ( u , v ) ≤δ ( u , x ) + δ ( x , v ) .
Background image of page 8