This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Algorithms Lecture 13: Shortest Paths Well, ya turn left by the fire station in the village and take the old post road by the reservoir and...no, that won’t do. Best to continue straight on by the tar road until you reach the schoolhouse and then turn left on the road to Bennett’s Lake until...no, that won’t work either. East Millinocket, ya say? Come to think of it, you can’t get there from here. — Robert Bryan and Marshall Dodge, Bert and I and Other Stories from Down East (1961) Hey farmer! Where does this road go? Been livin’ here all my life, it ain’t gone nowhere yet. Hey farmer! How do you get to Little Rock? Listen stranger, you can’t get there from here. Hey farmer! You don’t know very much do you? No, but I ain’t lost. — Michelle Shocked, “Arkansas Traveler" (1992) 13 Shortest Paths 13.1 Introduction Given a weighted directed graph G = ( V , E , w ) with two special vertices, a source s and a target t , we want to find the shortest directed path from s to t . In other words, we want to find the path p starting at s and ending at t minimizing the function w ( p ) = X e ∈ p w ( e ) . For example, if I want to answer the question ‘What’s the fastest way to drive from my old apartment in Champaign, Illinois to my wife’s old apartment in Columbus, Ohio?’, we might use a graph whose vertices are cities, edges are roads, weights are driving times, s is Champaign, and t is Columbus. 1 The graph is directed since the driving times along the same road might be different in different directions. 2 Perhaps counter to intuition, we will allow the weights on the edges to be negative. Negative edges make our lives complicated, since the presence of a negative cycle might mean that there is no shortest path. In general, a shortest path from s to t exists if and only if there is at least one path from s to t , but there is no path from s to t that touches a negative cycle. If there is a negative cycle between s and t , then se can always find a shorter path by going around the cycle one more time. s t 5 2-8 4 1 3 There is no shortest path from s to t . Every algorithm known for solving this problem actually solves (large portions of) the following more general single source shortest path or SSSP problem: find the shortest path from the source vertex s 1 West on Church, north on Prospect, east on I-74, south on I-465, east on Airport Expressway, north on I-65, east on I-70, north on Grandview, east on 5th, north on Olentangy River, east on Dodridge, north on High, west on Kelso, south on Neil. Depending on traffic. We both live in Urbana now. 2 In 1999 and 2000, there was a speed trap on I-70 just east of the Indiana / Ohio border, but only for eastbound traffic....
View Full Document
- Spring '09
- Graph Theory, Shortest path problem, shortest path, Edsger Dijkstra