Lecture 23 CSE 331 Oct 24, 2011
Online Office Hr @10:00-10:30pm
Shortest Path Problem http://xkcd.com/85/
Another more important application Is BGP a known acronym for you? Routing uses shortest path algorithm
Shortest Path problem s 100 Input: Directed graph G=(V,E) w 15 5 s u w 100 Input: Directed graph G=(V,E) Edge lengths, le for e in E “start” vertex s in V 15 5 s u w 5 s u Output: All shortest paths from s to all nodes in V
Dijkstra’s shortest path algorithm E. W. Dijkstra (1930-2002)
Dijkstra’s shortest path algorithm 1 d’(w) = min e=(u,w) in E, u in R d(u)+le 1 2 4 3 y 4 3 u d(s) = 0 d(u) = 1 s x 2 4 d(w) = 2 d(x) = 2 d(y) = 3 d(z) = 4 w z 5 4 2 s w Input: Directed G=(V,E), le ≥ 0, s in V u R = {s}, d(s) =0 Shortest paths x While there is a x not in R with (u,x) in E, u in R z y Pick w that minimizes d’(w) Add w to R d(w) = d’(w)
Couple of remarks The Dijkstra’s algo does not explicitly compute the shortest paths Can maintain “shortest path tree” separately Dijkstra’s algorithm does not work with negative weights Left as an exercise
Rest of Today’s agenda Prove the correctness of Dijkstra’s Algorithm Runtime analysis of Dijkstra’s Algorithm
Reading Assignment Sec 4.4 of [KT]
Building a fiber network Lay down fibers to connect n locations All n locations should be connected Laying down a fiber costs money What is the cheapest way to lay down the fibers?