Lecture21 - CSE 421 Algorithms Richard Anderson Lecture 21...

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

View Full Document Right Arrow Icon
CSE 421 Algorithms Richard Anderson Lecture 21 Shortest Paths
Background image of page 1

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

View Full DocumentRight Arrow Icon
Shortest Path Problem Dijkstra’s Single Source Shortest Paths Algorithm O(mlog n) time, positive cost edges General case – handling negative edges If there exists a negative cost cycle, the shortest path is not defined Bellman-Ford Algorithm O(mn) time for graphs with negative cost edges
Background image of page 2
Lemma If a graph has no negative cost cycles, then the shortest paths are simple paths Shortest paths have at most n-1 edges
Background image of page 3

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

View Full DocumentRight Arrow Icon
Shortest paths with a fixed number of edges Find the shortest path from v to w with exactly k edges
Background image of page 4
Express as a recurrence Opt k (w) = min x [Opt k-1 (x) + c xw ] • Opt 0 (w) = 0 if v=w and infinity otherwise
Background image of page 5

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

View Full DocumentRight Arrow Icon
Algorithm, Version 1 foreach w M[0, w] = infinity; M[0, v] = 0; for i = 1 to n-1 foreach w M[i, w] = min x (M[i-1,x] + cost[x,w]);
Background image of page 6
Algorithm, Version 2 foreach w M[0, w] = infinity; M[0, v] = 0; for i = 1 to n-1 foreach w M[i, w] = min(M[i-1, w], min x (M[i-1,x] + cost[x,w]))
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/25/2012 for the course CSE 421 taught by Professor Richardanderson during the Fall '06 term at University of Washington.

Page1 / 13

Lecture21 - CSE 421 Algorithms Richard Anderson Lecture 21...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online