Loading...

PPT – Shortest Paths PowerPoint presentation | free to download - id: 201f73-ZDc1Z

The Adobe Flash plugin is needed to view this content

Shortest Paths

Text Discrete Mathematics and Its Applications

(5th Edition) Kenneth H. Rosen Chapter 8.6 Based

on slides from Chuck Allison, Michael T.

Goodrich, and Roberto Tamassia By Longin Jan

Latecki

Weighted Graphs

Graphs that have a number assigned to each edge

are called weighted graphs.

Weighted Graphs

MILES

860

2534

191

1855

722

908

957

760

606

834

349

2451

1090

595

Weighted Graphs

FARES

129

79

39

99

59

69

89

79

99

89

129

39

69

Weighted Graphs

FLIGHT TIMES

405

210

050

255

150

210

220

155

140

245

350

200

115

130

Weighted Graphs

- A weighted graph is a graph in which each edge

(u, v) has a weight w(u, v). Each weight is a

real number. - Weights can represent distance, cost, time,

capacity, etc. - The length of a path in a weighted graph is the

sum of the weights on the edges. - Dijkstras Algorithm finds the shortest path

between two vertices.

(No Transcript)

(No Transcript)

(No Transcript)

(No Transcript)

(No Transcript)

(No Transcript)

(No Transcript)

Dijkstra's Algorithm

Dijkstra Animation

- Demo

(No Transcript)

Unprocessed node adjacent to 2 is 4. gt 1540

55 so replace with 55

(No Transcript)

Unprocessed node adjacent to 5 is 3. 35 gt 2010

30 so replace 35 with 30

Unprocessed node adjacent to 5 is 6. gt 2050

70 so replace with 70

Unprocessed node adjacent to 5 is 7. gt 2075

95 so replace with 95

(No Transcript)

Unprocessed node adjacent to 3 is 4. 55 lt 30 35

65 no change in array

(No Transcript)

Unprocessed node adjacent to 4 is 6. 70 gt 55 10

65 so replace 70 with 65

(No Transcript)

(No Transcript)

Unprocessed node adjacent to 6 is 7. 95 gt 65 15

80 so replace 95 with 80

(No Transcript)

All nodes have been processed Algorithm finishes.

Theorems

Dijkstras algorithm finds the length of a

shortest path between two vertices in a connected

simple undirected weighted graph.

Dijkstras algorithm uses O(n2) operations

(additions and comparisons) to find the length of

the shortest path between two vertices in a

connected simple undirected weighted graph.

Problem shortest path from a to z

f

b

d

5

5

4

7

3

1

4

2

a

z

4

3

c

e

g

5

5

a b c d e f g z

0 8 8 8 8 8 8 8

x 4(a) 3(a) 8 8 8 8 8

x x