lec41a - Lecture 41 SSSP with negative edge weights 20.2.4...

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

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

View Full Document

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

View Full Document

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.

Unformatted text preview: Lecture 41 SSSP with negative edge weights 20.2.4 Single-Source All-Destinations Shortest Paths With Negative Costs • Directed weighted graph. • Edges may have negative cost. • No cycle whose cost is < 0 . • Find a shortest path from a given source vertex s to each of the n vertices of the digraph. Single-Source All-Destinations Shortest Paths With Negative Costs • Dijkstra’s O(n 2 ) single-source greedy algorithm doesn’t work when there are negative-cost edges. • Floyd’s Θ (n 3 ) all-pairs dynamic-programming algorithm does work in this case. Bellman-Ford Algorithm • Single-source all-destinations shortest paths in digraphs with negative-cost edges. • Uses dynamic programming. • Runs in O(n 3 ) time when adjacency matrices are used. • Runs in O(ne) time when adjacency lists are used. Decision Sequence • To construct a shortest path from the source to vertex v , decide on – the max number of edges on the path and on – the vertex that comes just before v . • Since the digraph has no cycle whose length is < 0 , we may limit ourselves to the discovery of cycle- free (acyclic) shortest paths....
View Full Document

{[ snackBarMessage ]}

Page1 / 21

lec41a - Lecture 41 SSSP with negative edge weights 20.2.4...

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

View Full Document
Ask a homework question - tutors are online