Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shortest Path Problems

Similar presentations


Presentation on theme: "Shortest Path Problems"— Presentation transcript:

1 Shortest Path Problems

2 Introduction Many problems can be modeled using graphs with weights assigned to their edges: Airline flight times Telephone communication costs Computer networks response times

3 Where’s my motivation? Fastest way to get to school by car
Finding the cheapest flight home How much wood could a woodchuck chuck if a woodchuck could chuck wood?

4 Optimal driving time UCLA The Red Garter the beach (dude) In N’ Out
25 The Red Garter 19 5 9 the beach (dude) 21 16 31 In N’ Out 36 My cardboard box on Sunset

5 Tokyo Subway Map

6 Applications - Maps (Map Quest, Google Maps) - Routing Systems

7 Dijkstra's algorithm Steps: 1) Choose/given a starting point.
A solution to the single-source shortest path problem in graph theory.  Works on both directed and undirected graphs. Steps: 1) Choose/given a starting point. 2) Find the shortest path to the next vertex – label the vertex. 3) Label the remaining vertices from the shortest vertex. 4) Systematically check each vertex to be sure that they are labelled correctly.

8 Using the previous example, we will find the shortest path from a to c.
25 r 19 9 5 b 16 21 31 i 36 c

9 (a) = 0 25 (r) = 19 9 5 (b) = 16 21 31 (i) = 36 (c) =

10 (a) = 0 25 (r) = 19 9 5 (b) = 19 16 21 31 (i) = 36 (c) =

11 (a) = 0 25 (r) = 19 9 5 (b) = 19 16 21 31 (i) = 35 36 (c) =

12 (a) = 0 25 (r) = 24 19 9 5 (b) = 19 16 21 31 (i) = 35 36 (c) =

13 (a) = 0 25 (r) = 24 19 9 5 (b) = 19 16 21 31 (i) = 35 36 (c) = 50

14 (a) = 0 25 (r) = 24 19 9 5 (b) = 19 16 21 31 (i) = 9 36 (c) = 50

15 (a) = 0 25 (r) = 24 19 9 5 (b) = 19 16 21 31 (i) = 9 36 (c) = 50

16 (a) = 0 25 (r) = 24 19 9 5 (b) = 19 16 21 31 (i) = 9 36 (c) = 45

17 (a) = 0 25 (r) = 24 19 9 5 (b) = 19 16 21 31 (i) = 9 36 (c) = 45

18 Example ∞ Distance(source) = 0 Distance (all vertices but source) = ∞
Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 5 8 4 6 F 1 G Pick vertex in List with minimum distance.

19 Example: Initialization
Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 1 5 8 4 6 F 1 G

20 Example 2 Distance(source) = 0 Distance (all vertices but source) = ∞
2 Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 1 5 8 4 6 F 1 G

21 Example 2 Distance(source) = 0 Distance (all vertices but source) = ∞
2 Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 3 1 5 8 4 6 F 1 G

22 Example 2 Distance(source) = 0 Distance (all vertices but source) = ∞
2 Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 3 3 1 5 8 4 6 F 1 G

23 Example 2 Distance(source) = 0 Distance (all vertices but source) = ∞
2 Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 3 3 1 5 8 4 6 F 1 G 9

24 Example 2 Distance(source) = 0 Distance (all vertices but source) = ∞
2 Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 3 3 1 5 8 4 6 F 1 G 9 5

25 Example 2 Distance(source) = 0 Distance (all vertices but source) = ∞
2 Distance(source) = 0 Distance (all vertices but source) = ∞ A 2 B 4 1 3 10 C 2 D 2 E 3 3 1 5 8 4 6 F 1 G 6 5


Download ppt "Shortest Path Problems"

Similar presentations


Ads by Google