{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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

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

View Full Document
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 .
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

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

View Full Document
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.
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.

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

View Full Document
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:
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:

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

View Full Document
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 ) .