lecture_15

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

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

Introduction to Algorithms 6.046J/18.401J Prof. Charles E. Leiserson L ECTURE 15 Shortest Paths II Bellman-Ford algorithm DAG shortest paths Linear programming and difference constraints VLSI layout compaction

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

View Full Document
Introduction to Algorithms November 3, 2004 L15.2 © 2001–4 by Charles E. Leiserson Negative-weight cycles Recall: If a graph G = ( V , E ) contains a negative- weight cycle, then some shortest paths may not exist. Example: u u v v < 0
Introduction to Algorithms November 3, 2004 L15.3 © 2001–4 by Charles E. Leiserson Negative-weight cycles Recall: If a graph G = ( V , E ) contains a negative- weight cycle, then some shortest paths may not exist. Example: u u v v < 0 Bellman-Ford algorithm: Finds all shortest-path lengths from a source s V to all v V or determines that a negative-weight cycle exists.

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

View Full Document
Introduction to Algorithms November 3, 2004 L15.4 © 2001–4 by Charles E. Leiserson Bellman-Ford algorithm d [ s ] 0 for each v V –{ s } do d [ v ] ←∞ for i 1 to | V | –1 do for each edge ( u , v ) E do if d [ v ] > d [ u ] + w ( u , v ) then d [ v ] d [ u ] + w ( u , v ) for each edge ( u , v ) E do if d [ v ] > d [ u ] + w ( u , v ) then report that a negative-weight cycle exists initialization At the end, d [ v ] = δ ( s , v ) , if no negative-weight cycles. Time = O ( VE ) . relaxation step
Introduction to Algorithms November 3, 2004 L15.5 © 2001–4 by Charles E. Leiserson Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3

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

View Full Document
Introduction to Algorithms November 3, 2004 L15.6 © 2001–4 by Charles E. Leiserson Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 ∞∞ Initialization.
Introduction to Algorithms November 3, 2004 L15.7 © 2001–4 by Charles E. Leiserson Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 ∞∞ 1 2 3 4 5 7 8 Order of edge relaxation. 6

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

View Full Document
Introduction to Algorithms November 3, 2004 L15.8 © 2001–4 by Charles E. Leiserson Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 ∞∞ 1 2 3 4 5 7 8 6
Introduction to Algorithms November 3, 2004 L15.9 © 2001–4 by Charles E. Leiserson Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 ∞∞ 1 2 3 4 5 7 8 6

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

View Full Document
Introduction to Algorithms November 3, 2004 L15.10 © 2001–4 by Charles E. Leiserson Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 ∞∞ 1 2 3 4 5 7 8 6
Introduction to Algorithms November 3, 2004 L15.11 © 2001–4 by Charles E. Leiserson −1 Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 ∞∞ 1 2 3 4 5 7 8 6

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

View Full Document
Introduction to Algorithms November 3, 2004 L15.12 © 2001–4 by Charles E. Leiserson 4 −1 Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 1 2 3 4 5 7 8 6
Introduction to Algorithms November 3, 2004 L15.13 © 2001–4 by Charles E. Leiserson 4 −1 Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 1 2 3 4 5 7 8 6

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

View Full Document
Introduction to Algorithms November 3, 2004 L15.14 © 2001–4 by Charles E. Leiserson 4 2 −1 Example of Bellman-Ford A A B B E E C C D D –1 4 1 2 –3 2 5 3 0 1 2 3 4 5 7 8 6
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/10/2008 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

### Page1 / 45

lecture_15 - Introduction to Algorithms 6.046J/18.401J...

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

View Full Document
Ask a homework question - tutors are online