This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Lecture 41 SSSP with negative edge weights 20.2.4 SingleSource AllDestinations 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. SingleSource AllDestinations Shortest Paths With Negative Costs • Dijkstra’s O(n 2 ) singlesource greedy algorithm doesn’t work when there are negativecost edges. • Floyd’s Θ (n 3 ) allpairs dynamicprogramming algorithm does work in this case. BellmanFord Algorithm • Singlesource alldestinations shortest paths in digraphs with negativecost 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
 Fall '08
 Davis

Click to edit the document details