lec402 - All-Pairs Shortest Paths Given an n- vertex...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: All-Pairs Shortest Paths Given an n- vertex directed weighted graph, find a shortest path from vertex i to vertex j for each of the n 2 vertex pairs (i,j) . 1 2 3 4 5 6 7 5 7 1 7 9 1 9 4 4 5 16 4 2 8 1 2 Dijkstras Single Source Algorithm Use Dijkstras algorithm n times, once with each of the n vertices as the source vertex. 1 2 3 4 5 6 7 5 7 1 7 9 1 9 4 4 5 16 4 2 8 1 2 Performance Time complexity is O(n 3 ) time. Works only when no edge has a cost < 0 . Dynamic Programming Solution Time complexity is Theta(n 3 ) time. Works so long as there is no cycle whose length is < 0 . When there is a cycle whose length is < 0 , some shortest paths arent finite. If vertex 1 is on a cycle whose length is-2 , each time you go around this cycle once you get a 1 to 1 path that is 2 units shorter than the previous one. Simpler to code, smaller overheads. Known as Floyds shortest paths algorithm. Decision Sequence First decide the highest intermediate vertex (i.e., largest vertex number) on the shortest path from i to j . If the shortest path is i, 2, 6, 3, 8, 5, 7, j the first decision is that vertex 8 is an intermediate vertex on the shortest path and no intermediate vertex is larger than 8 . Then decide the highest intermediate vertex on the path from i to 8 , and so on. i j Problem State (i,j,k) denotes the problem of finding the shortest path from vertex i to vertex j that has no intermediate vertex larger than k . (i,j,n) denotes the problem of finding the shortest path from vertex i to vertex j (with no restrictions on intermediate vertices)....
View Full Document

This note was uploaded on 01/18/2012 for the course COP 3530 taught by Professor Davis during the Fall '08 term at University of Florida.

Page1 / 15

lec402 - All-Pairs Shortest Paths Given an n- vertex...

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

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