start presentation

9
A Step by Step Analysis of Dijkstra’s Algorithm Henry Chen

Upload: henry-chen

Post on 12-Apr-2017

23 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: START Presentation

A Step by Step Analysis of Dijkstra’s

AlgorithmHenry Chen

Page 2: START Presentation

Dijkstra’s Algorithm• A graph search algorithm that solves the single-source shortest path

problem for a graph• Considered the fundamental shortest-path algorithm

Page 3: START Presentation

Algorithm1. Assign to every node a tentative distance value2. Mark all nodes unvisited, set current node to A3. For each current node, consider all unvisited

neighbors and calculate their tentative distance. Replace current distance if smaller.

4. After all neighbors are checked, current marked as visited, and current is set to the smallest unvisited node

5. Stop when G is reached

A

B F

C

E

G

D

30 20

50

10

20

90 2080

40

10

1050

Page 4: START Presentation

A

B F

C

E

G

D

30 20

50

10

20

90 2080

40

10

1050

B C D E F G∞ ∞ ∞ ∞ ∞ ∞

- - - - - -

20

A

80

A

90

A

Page 5: START Presentation

A

B F

C

E

G

D

30 20

50

10

20

90 2080

40

10

1050

B C D E F G20 ∞ 80 ∞ ∞ 90

A - A - - A

30

B

40

F

70

F

FB

Page 6: START Presentation

A

B F

C

E

G

D

30 20

50

10

20

90 2080

40

10

1050

B C D E F G20 40 70 ∞ 30 90

A F F - B A

50

C

70

D

C D

Page 7: START Presentation

A

B F

C

E

G

D

30 20

50

10

20

90 2080

40

10

1050

B C D E F G20 40 50 ∞ 30 70

A F C - B D

C

GDCFBA

Page 8: START Presentation

Efficiency of Dijkstra’s Algorithm

Dijkstra’s A* Search

• Other algorithms are usually compared to Dijkstra’s algorithm for efficiency

Page 9: START Presentation

Questions?