Lecture 24 CSE 331 Oct 30, 2009

advertisement

Lecture 24

CSE 331

Oct 30, 2009

Homework stuff

Please turn in your HW 6

Graded HW 5 and HW 7 at the END of the lecture

Group talk time

Form groups of size at most 4

You should always sit with your group

DO THIS NOW!

Pick a group leader who is responsible for asking group’s questions

The groups and group leader can change from lecture to lecture

s

Dijkstra’s shortest path algorithm

1 u

3 y d’(v) = min e=(u,v) in E , u in S d(u)+l e

1

2

4

2 v

1

2

3

1 x z

2 d(s) = 0 d(v) = 2 d(y) = 3 s d(u) = 1 d(x) = 2 d(z) = 4

Input: Directed G=(V,E) , l e

≥ 0 , s in V u v

S = {s} , d(s) =0

While there is a v not in S with (u,v) in E , u in S

Shortest paths x

Pick w that minimizes d’(w)

Add w to S d(w) = d’(w) y z

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

Q1 in HW 7

Today’s agenda

Prove correctness of Dijkstra’s algorithm

Efficient implementation of Dijkstra’s algorithm

s

Dijkstra’s shortest path algorithm

1 u

3 y d’(v) = min e=(u,v) in E , u in S d(u)+l e

1

2

4

2 v

1

2

3

1 x z

2 d(s) = 0 d(v) = 2 d(y) = 3 s d(u) = 1 d(x) = 2 d(z) = 4

Input: Directed G=(V,E) , l e

≥ 0 , s in V u v

S = {s} , d(s) =0

While there is a v not in S with (u,v) in E , u in S

Shortest paths x

Pick w that minimizes d’(w)

Add w to S d(w) = d’(w) y z

Reading Assignment

Sec 4.4 of [KT]

Download