{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture_10

# lecture_10 - Shortest paths revisited Input a weighted...

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

Shortest paths revisited Input: square4 a weighted directed graph G = (V,E) square4 edge weight w(e) can be +ve or –ve ; square4 vertexes s and t To find: the shortest (smallest weight) path from s to t (s-t path). Recall that the proof of Dijkstra’s algorithm fails if there are –ve edge weight. Indeed, Dijkstra’s algorithm doesn’t work in the presence of –ve edge. s u v t 2 3 1 -6

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

View Full Document
Negative edge weights A quick fix: Add a “big” number to each edge to ensure the edge weight is positive. E.g., Add 6 to every edge. u 3+6 2 Does it work? No, the shortest path is not preserved. s v t 2+6 1+6 -6+6
Background – negative cycles Fact. If a path from s to t contains a negative cycle, then there doesn’t exists a shortest path from s to t . Intuitively, the path can go through the loop many times to make the total weight smaller than any number. 3 It remains to consider the case when G has negative edges but no negative cycles. s t weight of cycle < 0

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

View Full Document
Background – no negative cycles Lemma. Assume that no s-t path contains a negative cycle. Then there exists a shortest s-t path that is a simple path (no duplicate vertexes).
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}