lecture_15

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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.
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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.
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
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
Background image of page 12
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
Background image of page 13

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

View Full DocumentRight Arrow Icon
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
Background image of page 14
Image of page 15
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 Right Arrow Icon
Ask a homework question - tutors are online