Download presentation
Presentation is loading. Please wait.
1
Lecture 24 CSE 331 Oct 29, 2018
2
Mini Project video due in 1 week
3
Peer Evaluation Survey
Some more details by Tuesday
4
HW 5 grading delayed (more)
New plan to get it done by tonight
5
Re-grade deadlines
6
Mid-term temp grades
7
One-on-one meeting slots
8
Shortest Path Problem
9
Another more important application
Is BGP a known acronym for you? Routing uses shortest path algorithm
10
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: Length of shortest paths from s to all nodes in V
11
Dijkstra’s shortest path algorithm
E. W. Dijkstra ( )
12
Towards Dijkstra’s algo: part ek
Determine d(t) one by one s d(s) = 0 u x y
13
Towards Dijkstra’s algo: part do
Determine d(t) one by one s Let u be a neighbor of s with smallest l(s,u) 3 4 100 u x y d(u) = l(s,u) Not making any claim on other vertices
14
Towards Dijkstra’s algo: part teen
Determine d(t) one by one R Assume we know d(v) for evert v in R s u x y w Compute an upper bound d’(w) for every w not in R d(w) d(u) + l(u,w) d(w) d(x) + l(x,w) d’(w) = min e=(u,w) in E, u in R d(u)+le d(w) d(y) + l(y,w)
15
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)
16
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
17
Rest of Today’s agenda Prove the correctness of Dijkstra’s Algorithm
Runtime analysis of Dijkstra’s Algorithm
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.