22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest...

12
22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston

Transcript of 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest...

Page 1: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

22

15

3214

21

1016Liskeard

Launceston

Callington

St Austell

Bodmin

StarterFind the quickest route from St Austell to Launceston

Page 2: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

Dijkstra’s Algorithm

Aims:To be able to use Dijkstra’s algorithm to find the shortest path between two vertices on a

network

Page 3: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.
Page 4: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

Dijkstra’s Algorithm

• Invented by Edgar Dijkstra.• Dutch computer scientist.• Lived from 1930 to 2002.• Worked at the University

of Texas at Austin.• Received many awards for

his work in computer science.

Page 5: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

Dijkstra’s Algorithm

• Is used to find the shortest path between two places.

• It does this by using temporary labels.• These keep track on the best way to get to

each place.• When you are sure you have the shortest way

you can make this a permanent label.• Let’s have a go!

Page 6: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

22

15

3214

21

1016Liskeard

Launceton

Callington

St Austell

Bodmin

Use Dijkstra’s Algorithmto find the quickest route from St Austell to Launceston

Page 7: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

Dijkstra’s Step-by-Step1) Label the starting vertex with 0. Place in a square box to

show a permanent label.2) Consider every vertex that connects to the starting and give

a temporary label.3) Put a box around the shortest temporary label, making it a

permanent label.4) Consider every place that connects to the new permanent

label. a) Add temporary labels to places that do not have one. b) If there is a shorter way to get to a place already temporary

labelled cross out and write the sorter distance down. c) If the distance is longer than the existing label do nothing .

5) Repeat steps 3 and 4 until complete.6) Follow the backwards to find the shortest route.

Page 8: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

A B

C

D

E

F

2

2

21

1

55

5

64

4

Find the shortest path from A to F and state the route taken.

Page 9: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

Find the shortest path from A to G and state the route taken.

Page 10: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

Find the shortest path from A to G and state the route taken.

Page 11: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.

Find the shortest path from F to C and state the route taken.

Page 12: 22 15 32 14 21 10 16 Liskeard Launceston Callington St Austell Bodmin Starter Find the quickest route from St Austell to Launceston.