Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 26 CSE 331 Nov 1, 2010.

Similar presentations


Presentation on theme: "Lecture 26 CSE 331 Nov 1, 2010."— Presentation transcript:

1 Lecture 26 CSE 331 Nov 1, 2010

2 Blog posts/Group Scribe leader
Please sign up if you have not There are many lectures even in November with <3 students If I have a pick a blogger/leader I will only pick THREE/lecture Will lose out on 5%-10% of your grade

3 Shortest Path problem 15 5 s u v 100 Input: Directed graph G=(V,E)
Edge lengths, le for e in E “start” vertex s in V 15 5 s u v Output: All shortest paths from s to v in V 5 s u

4 Naïve Algorithm Ω(n!) time

5 Dijkstra’s shortest path algorithm
E. W. Dijkstra ( )

6 Dijkstra’s shortest path algorithm
1 d’(v) = min e=(u,v) 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(v) = 2 d(x) = 2 d(y) = 3 d(z) = 4 v z 5 4 2 s v Input: Directed G=(V,E), le ≥ 0, s in V u R = {s}, d(s) =0 Shortest paths x While there is a v not in R with (u,v) in E, u in R z y Pick w that minimizes d’(w) Add w to R d(w) = d’(w)

7 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

8 Rest of today’s agenda Prove correctness of Dijkstra’s algorithm
Efficient implementation of Dijkstra’s algorithm


Download ppt "Lecture 26 CSE 331 Nov 1, 2010."

Similar presentations


Ads by Google