Top Banner
Lecture 23 CSE 331 Oct 24, 2011
12

Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Jan 29, 2016

Download

Documents

Louisa Sutton
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Lecture 23

CSE 331Oct 24, 2011

Page 2: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Reminder

2 points for Piazza participation

3 points for mini-project

Page 3: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Online Office Hr @10:00-11:00pm

Page 4: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Shortest Path Problem

http://xkcd.com/85/

Page 5: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Another more important application

Is BGP a known acronym for you?

Routing uses shortest path algorithm

Page 6: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

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

Page 7: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Dijkstra’s shortest path algorithmE. W. Dijkstra (1930-2002)

Page 8: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

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

Page 9: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

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

Page 10: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Rest of Today’s agenda

Prove the correctness of Dijkstra’s Algorithm

Runtime analysis of Dijkstra’s Algorithm

Page 11: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

Reading AssignmentSec 4.4 of [KT]

Page 12: Lecture 23 CSE 331 Oct 24, 2011. Reminder 2 points for Piazza participation 3 points for mini-project.

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?