{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

18-Shortest-Paths-II

# 18-Shortest-Paths-II - Algorithms LECTURE 18 Shortest Paths...

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

Algorithms L18.1 Professor Ashok Subramanian L ECTURE 18 Shortest Paths II Bellman-Ford algorithm Linear programming and difference constraints VLSI layout compaction Algorithms

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

View Full Document
Algorithms 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 v < 0
Algorithms 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 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
Algorithms L18.4 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 ( V E ) . relaxation step
Algorithms L18.5 Example of Bellman-Ford A B E C 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
Algorithms L18.6 Example of Bellman-Ford A B E C D –1 4 1 2 –3 2 5 3 0 Initialization.
Algorithms L18.7 Example of Bellman-Ford A B E C 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
Algorithms L18.8 Example of Bellman-Ford A B E C D –1 4 1 2 –3 2 5 3 0 1 2 3 4 5 7 8 6
Algorithms L18.9 Example of Bellman-Ford A B E C 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
Algorithms L18.10 Example of Bellman-Ford A B E C D –1 4 1 2 –3 2 5 3 0 1 2 3 4 5 7 8 6
Algorithms L18.11 -1 Example of Bellman-Ford A B E C 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
Algorithms L18.12 4 -1 Example of Bellman-Ford A B E C D –1 4 1 2 –3 2 5 3 0 1 2 3 4 5 7 8 6
Algorithms L18.13 4 -1 Example of Bellman-Ford A B E C 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
Algorithms L18.14 4 2 -1 Example of Bellman-Ford A B E C D –1 4 1 2 –3 2 5 3 0 1 2 3 4 5 7 8 6
Algorithms L18.15 2 -1 Example of Bellman-Ford A B E C 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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}