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

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

View Full Document Right Arrow Icon
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.1 Introduction to Algorithms 6.046J/18.401J L ECTURE 18 Shortest Paths II Bellman-Ford algorithm Linear programming and difference constraints VLSI layout compaction 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 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.2 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.3 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.4 Bellman-Ford algorithm d [ s ] 0 for each v V –{ s } do d [ v ] ←∞ initialization 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 relaxation step At the end, d [ v ] = δ ( s , v ) , if no negative-weight cycles. Time = O ( VE ) .
Background image of page 4
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.5 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.6 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.7 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 Order of edge relaxation.
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 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.8 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.9 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.10 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.11 Example of Bellman-Ford −1 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.12 Example of Bellman-Ford 4 −1 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.13 Example of Bellman-Ford 4 −1 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
November 16, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L18.14 Example of Bellman-Ford 4 2 −1 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 10/19/2010 for the course CS 477 taught by Professor Gewali during the Spring '08 term at University of Nevada, Las Vegas.

Page1 / 45

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

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