{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture_14

# lecture_14 - Introduction to Algorithms 6.046J/18.401J...

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

Introduction to Algorithms 6.046J/18.401J Prof. Charles E. Leiserson L ECTURE 14 Shortest Paths I Properties of shortest paths Dijkstra’s algorithm Correctness Analysis Breadth-first search

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

View Full Document
Introduction to Algorithms November 1, 2004 L14.2 © 2001–4 by Charles E. Leiserson 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 .
Introduction to Algorithms November 1, 2004 L14.3 © 2001–4 by Charles E. Leiserson 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 –5 1 Example: w ( p ) = –2

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

View Full Document
Introduction to Algorithms November 1, 2004 L14.4 © 2001–4 by Charles E. Leiserson 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.
Introduction to Algorithms November 1, 2004 L14.5 © 2001–4 by Charles E. Leiserson 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
Introduction to Algorithms November 1, 2004 L14.6 © 2001–4 by Charles E. Leiserson Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Proof. Cut and paste:
Introduction to Algorithms November 1, 2004 L14.7 © 2001–4 by Charles E. Leiserson 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
Introduction to Algorithms November 1, 2004 L14.8 © 2001–4 by Charles E. Leiserson Triangle inequality Theorem. For all u , v , x V , we have δ ( u , v ) ≤ δ ( u , x ) + δ ( x , v ) .
Introduction to Algorithms November 1, 2004 L14.9 © 2001–4 by Charles E. Leiserson Triangle inequality Theorem. For all u , v , x V , we have δ ( u , v ) ≤ δ ( u , x ) + δ ( x , v ) . u u Proof. x x v v δ ( u , v ) δ ( u , x ) δ ( x , v )

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

View Full Document
Introduction to Algorithms November 1, 2004 L14.10 © 2001–4 by Charles E. Leiserson Well-definedness of shortest paths If a graph G contains a negative-weight cycle, then some shortest paths may not exist.