ShortestPaths

ShortestPaths - Subhash Suri UC Santa Barbara CS-230b...

Info iconThis preview shows pages 1–8. 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

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: Subhash Suri UC Santa Barbara CS-230b Advanced Algorithms and Applications Subhash Suri Computer Science Department UC Santa Barbara Fall Quarter 2004. Subhash Suri UC Santa Barbara Shortest Paths u v s 10 1 5 7 2 3 x y 2 9 6 Find shortest length path from s to v ? s x u v has length 5 + 3 + 1 = 9 . Many applications. Discussed later. A network G = ( V, E ) . Vertices (nodes) V = { 1 , . . . , n } . Edges (links) E = { e 1 , e 2 , . . . , e m } . Edge e ij = ( i, j ) is directed from i to j . Edge e ij has cost (weight) c ij . The costs can be positive or negative! Subhash Suri UC Santa Barbara Negative Cost Shortest Paths v s x y 7 6 2 5 9-3-4-2 8 7 u Whats the shortest path from s to y ? s x v u y has length- 2 . How can costs be negative? Examples later. (Arbitrage trading, scientific simulations, matching algorithms, min cost network flows). More general the formulation, the better. Any simple way to eliminate negative edges? Adding a constant to all edges? Subhash Suri UC Santa Barbara Getting Started u v s 10 1 5 7 2 3 x y 2 9 6 Source node s = v . Compute SP distances from s to every node v j . The paths themselves can be recovered from predecessors. Distance labels d ( j ) : best path length to j found so far. Initially, d (0) = 0 , and d ( j ) = for others. The algorithm improves estimates for all d ( j ) until SP distances become known. Subhash Suri UC Santa Barbara Basic Idea How to improve the distance estimate? s c ij i j 50 75 10 Suppose there is an edge ( i, j ) such that d ( j ) > d ( i ) + c ij then we can improve the estimate of d ( j ) : d ( j ) = d ( i ) + c ij Previously, d ( i ) = 50 and d ( j ) = 75 . The relabeling step finds a better path to j via i of cost 60 . Subhash Suri UC Santa Barbara Optimality Condition Theorem: Suppose each d ( j ) is the length of some feasible path from s to j . Then, these d () distances are shortest path distance if and only if d ( j ) d ( i ) + c ij , for all ( i, j ) E u v s 10 1 5 7 2 3 x y 2 9 6 8 9 5 7 Necessity Proof: Suppose an edge ( i, j ) violating the condition. Then, d ( j ) > d ( i ) + c ij . But then we can reach j via i at cost d ( i ) + c ij , which is smaller than d ( j ) , contradicting the d ( j ) is shortest path distance. Subhash Suri UC Santa Barbara Sufficiency s 1 2 k-1 k c c c 01 12 k-1,k 1. Suppose d ( j ) d ( i ) + c ij holds. 2. Let k be a node with incorrect distance. 3. s 1 2 k- 1 k be actual SP. 4. So, c 01 + c 12 + + c k- 1 ,k < d ( k ) . ( * ) 5. By optimality condition we have d ( k ) d ( k- 1) + c k- 1 ,k d ( k- 1) d ( k- 2) + c k- 2 ,k- 1 ....
View Full Document

This note was uploaded on 12/27/2011 for the course CMPSC 225 taught by Professor Vandam during the Fall '09 term at UCSB.

Page1 / 52

ShortestPaths - Subhash Suri UC Santa Barbara CS-230b...

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