lecture 23 cse 331 oct 24, 2011. reminder 2 points for piazza participation 3 points for...
TRANSCRIPT
Lecture 23
CSE 331Oct 24, 2011
Reminder
2 points for Piazza participation
3 points for mini-project
Online Office Hr @10:00-11:00pm
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
Input: Directed graph G=(V,E)
Edge lengths, le for e in E
“start” vertex s in V
Output: All shortest paths from s to all nodes in V
100
155
s
u
w
5
s
u
155
s
u
w
Dijkstra’s shortest path algorithmE. W. Dijkstra (1930-2002)
Dijkstra’s shortest path algorithm
Input: Directed G=(V,E), le ≥ 0, s in V
R = {s}, d(s) =0
While there is a x not in R with (u,x) in E, u in R
d’(w) = min e=(u,w) in E, u in R d(u)+le
Pick w that minimizes d’(w) Add w to Rd(w) = d’(w)
ss
ww
uu
zz
xx
yy
1
2
4
3
3
1
2
1
2
d(s) = 0
1
4
2 ss
uu
d(u) = 1
4
2
ww
d(w) = 2
5
xx
d(x) = 2
3
4
yy
d(y) = 3
zz
d(z) = 4
Shortest paths
Shortest paths
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 AssignmentSec 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?