Floyd’s Algorithm can be used to help solve Travelling Salesman

48
page 1 M B L A X 48 20 10 19 18 7 10 23 Floyd’s Algorithm can be used to help solve Travelling Salesman and other shortest routes problems. Floyd’s uses a matrix form.

description

M. 48. B. 19. 10. 23. 20. L. 10. 7. 18. A. X. Floyd’s Algorithm can be used to help solve Travelling Salesman and other shortest routes problems. Floyd’s uses a matrix form. To look back at the network click here:. D( 0 ). R( 0 ). This is the route matrix. - PowerPoint PPT Presentation

Transcript of Floyd’s Algorithm can be used to help solve Travelling Salesman

Page 1: Floyd’s Algorithm can be used to help solve Travelling Salesman

page 1

MB

L

AX

48

20

10 19

18

710

23

Floyd’s Algorithm can be used to help solve Travelling Salesman and other shortest routes problems.

Floyd’s uses a matrix form.

Page 2: Floyd’s Algorithm can be used to help solve Travelling Salesman

page 2

D( 0 ) R( 0 )

This is the distance matrix. It initially shows the direct distance between one vertex and the others. The infinity sign denotes no direct route.

This is the route matrix.It will eventually show the next vertex that needs to be taken on route to finding theshortest route to another vertex.

•To view the process step by step click here

•To view the completed matrices click here

A M L B X

A 23 10 18

M 23 10 48

L 10 10 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

To look back at the network click here:

Page 3: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Click here to see step:

A M L B X

A 23 10 18

M 23 10 48

L 10 10 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

Page 4: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

23 + 23 = 46, less than so change.

A M L B X

A 23 10 18

M 23 10 48

L 10 10 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 5: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

23 + 23 = 46, less than so change.

A M L B X

A 23 10 18

M 23 46 10 48

L 10 10 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 6: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

10 + 23 = 33, so we leave this item

A M L B X

A 23 10 18

M 23 46 10 48

L 10 10 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 7: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

When is involved we leave the item.

A M L B X

A 23 10 18

M 23 46 10 48

L 10 10 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 8: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

18 + 23 = 41, so we replace the item.

A M L B X

A 23 10 18

M 23 46 10 48

L 10 10 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 9: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

18 + 23 = 41, so we replace the item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 19 7

B 48 19 20

X 18 7 20

C A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 10: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

23 + 10 = 33, so we leave this item.

48 41

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 19 7

B 48 19 20

X 18 7 20

C A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 11: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

10 + 10 = 20, so we replace this item.

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 12: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

Infinity is involved so we leave this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 13: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

18 + 10 = 28 which is more than 7 so we leave this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 14: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

Infinity is involved so we leave this item.

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 15: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

Infinity is involved so we leave this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 16: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

Infinity is involved so we leave this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 17: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

Infinity is involved so we leave this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 18: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

We replace this item with23 + 18 = 41

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 19: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

We replace this item with23 + 18 = 41

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 20: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

10 + 18 = 28, 7 is less than thisso leave it.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 21: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

Infinity is involved so leave this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 22: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

18 + 18 = 36, so replace this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 23: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

18 + 18 = 36, so replace this item.

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

We highlight the first column and row of the Distance matrix and compare all other items with the sum of the items highlighted in the same row and column. If the sum is less than the item then it should be replaced with the sum.

Page 24: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 0 ) R( 0 )

Click here to see step:

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

A M L B X

A 1 2 3 4 5

M 1 2 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

Page 25: Floyd’s Algorithm can be used to help solve Travelling Salesman

R( 0 )

Click here to see step:

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

A M L B X

A 1 2 3 4 5

M 1 1 3 4 5

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

D( 0 )

Page 26: Floyd’s Algorithm can be used to help solve Travelling Salesman

R( 0 )

Click here to see step:

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

D( 0 )

A M L B X

A 1 2 3 4 5

M 1 1 3 4 1

L 1 2 3 4 5

B 1 2 3 4 5

X 1 2 3 4 5

Page 27: Floyd’s Algorithm can be used to help solve Travelling Salesman

R( 0 )

Click here to see step:

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

D( 0 )

A M L B X

A 1 2 3 4 5

M 1 1 3 4 1

L 1 2 1 4 5

B 1 2 3 4 5

X 1 2 3 4 5

Page 28: Floyd’s Algorithm can be used to help solve Travelling Salesman

R( 0 )

Click here to see step:

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

D( 0 )

A M L B X

A 1 2 3 4 5

M 1 1 3 4 1

L 1 2 1 4 5

B 1 2 3 4 5

X 1 1 3 4 5

Page 29: Floyd’s Algorithm can be used to help solve Travelling Salesman

R( 0 )

Click here to see step:

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

D( 0 )

A M L B X

A 1 2 3 4 5

M 1 1 3 4 1

L 1 2 1 4 5

B 1 2 3 4 5

X 1 1 3 4 1

Page 30: Floyd’s Algorithm can be used to help solve Travelling Salesman

We have now completed one iteration. We rename the new matrices:

Click here to see step:

Subsequent iterations are now shown completed:

Click here to see final matrices:

R( 1 )D( 1 )

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

A M L B X

A 1 2 3 4 5

M 1 1 3 4 1

L 1 2 1 4 5

B 1 2 3 4 5

X 1 1 3 4 1

Page 31: Floyd’s Algorithm can be used to help solve Travelling Salesman

Click here to see step:

Subsequent iterations are now shown completed:

Click here to see final matrices:

R( 1 )D( 1 )

A M L B X

A 23 10 18

M 23 46 10 48 41

L 10 10 20 19 7

B 48 19 20

X 18 41 7 20 36

A M L B X

A 1 2 3 4 5

M 1 1 3 4 1

L 1 2 1 4 5

B 1 2 3 4 5

X 1 1 3 4 1

Page 32: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 1 ) R( 1 )

The items have been altered accordingly:

Click here to see step:

Subsequent iterations are now shown completed:

Click here to see final matrices:

A M L B X

A 46 23 10 71 18

M 23 46 10 48 41

L 10 10 20 19 7

B 71 48 19 96 20

X 18 41 7 20 36

A M L B X

A 1 2 3 4 5

M 1 1 3 4 1

L 1 2 1 4 5

B 1 2 3 4 5

X 1 1 3 4 1

Page 33: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 2 ) R( 2 )

We can now rename the matrices:

Click here to see step:

Click here to see final matrices:

A M L B X

A 46 23 10 71 18

M 23 46 10 48 41

L 10 10 20 19 7

B 71 48 19 96 20

X 18 41 7 20 36

A M L B X

A 2 2 3 2 5

M 1 1 3 4 1

L 1 2 1 4 5

B 2 2 3 2 5

X 1 1 3 4 1

Page 34: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 2 ) R( 2 )

Next iteration:

Click here to see step:

Click here to see final matrices:

A M L B X

A 46 23 10 71 18

M 23 46 10 48 41

L 10 10 20 19 7

B 71 48 19 96 20

X 18 41 7 20 36

A M L B X

A 2 2 3 2 5

M 1 1 3 4 1

L 1 2 1 4 5

B 2 2 3 2 5

X 1 1 3 4 1

Page 35: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 2 ) R( 2 )

Next iteration, the items are altered appropriately :

Click here to see step:

Click here to see final matrices:

A M L B X

A 20 20 10 29 17

M 20 20 10 29 17

L 10 10 20 19 7

B 29 29 19 38 20

X 17 17 7 20 14

A M L B X

A 3 3 3 3 3

M 3 3 3 3 3

L 1 2 1 4 5

B 3 3 3 3 5

X 3 3 3 4 3

Page 36: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 3 ) R( 3 )

The matrices are renamed :

Click here to see step:

Click here to see final matrices:

A M L B X

A 20 20 10 29 17

M 20 20 10 29 17

L 10 10 20 19 7

B 29 29 19 38 20

X 17 17 7 20 14

A M L B X

A 3 3 3 3 3

M 3 3 3 3 3

L 1 2 1 4 5

B 3 3 3 3 5

X 3 3 3 4 3

Page 37: Floyd’s Algorithm can be used to help solve Travelling Salesman

The next iteration :

Click here to see step:

Click here to see final matrices:

D( 3 ) R( 3 )

A M L B X

A 20 20 10 29 17

M 20 20 10 29 17

L 10 10 20 19 7

B 29 29 19 38 20

X 17 17 7 20 14

A M L B X

A 3 3 3 3 3

M 3 3 3 3 3

L 1 2 1 4 5

B 3 3 3 3 5

X 3 3 3 4 3

Page 38: Floyd’s Algorithm can be used to help solve Travelling Salesman

In this iteration, you do not need to change any of the items, so we go onto the next iteration :

Click here to see step:

Click here to see final matrices:

D( 3 ) R( 3 )

A M L B X

A 20 20 10 29 17

M 20 20 10 29 17

L 10 10 20 19 7

B 29 29 19 38 20

X 17 17 7 20 14

A M L B X

A 3 3 3 3 3

M 3 3 3 3 3

L 1 2 1 4 5

B 3 3 3 3 5

X 3 3 3 4 3

Page 39: Floyd’s Algorithm can be used to help solve Travelling Salesman

Click here to see step:

Click here to see final matrices:

A M L B X

A 20 20 10 29 17

M 20 20 10 29 17

L 10 10 20 19 7

B 29 29 19 38 20

X 17 17 7 20 14

A M L B X

A 3 3 3 3 3

M 3 3 3 3 3

L 1 2 1 4 5

B 3 3 3 3 5

X 3 3 3 4 3

D( 4 ) R( 4 )

Page 40: Floyd’s Algorithm can be used to help solve Travelling Salesman

Click here to see step:

Click here to see final matrices:

There is only one item that we need to change in this case:

D( 4 ) R( 4 )

A M L B X

A 20 20 10 29 17

M 20 20 10 29 17

L 10 10 14 19 7

B 29 29 19 38 20

X 17 17 7 20 14

A M L B X

A 3 3 3 3 3

M 3 3 3 3 3

L 1 2 1 4 5

B 3 3 3 3 5

X 3 3 3 4 3

Page 41: Floyd’s Algorithm can be used to help solve Travelling Salesman

These are the final matrices, remember that you can use them to redraw the original network. You can then use this to help us solve travelling salesman problems:

Click here to see new network:

D( 5 ) R( 5 )

A M L B X

A 20 20 10 29 17

M 20 20 10 29 17

L 10 10 14 19 7

B 29 29 19 38 20

X 17 17 7 20 14

A M L B X

A 3 3 3 3 3

M 3 3 3 3 3

L 1 2 5 4 5

B 3 3 3 3 5

X 3 3 3 4 3

Page 42: Floyd’s Algorithm can be used to help solve Travelling Salesman

page 1

MB

L

AX

29

20

10 19

17

710

20

29

17

This network now gives you a better idea of the quickest routes.

Click below to try a question:

The route matrix gives us an idea about the next vertex to visit on route - 1 represents A, 2 - M, etc.

Page 43: Floyd’s Algorithm can be used to help solve Travelling Salesman

1

5

4

3

2

75 35

32

15

40

30

70

Try this one! Click below when you have completed it to check the answers:

Page 44: Floyd’s Algorithm can be used to help solve Travelling Salesman

1 2 3 4 5

1 60 30 40 45 77

2 30 30 50 15 47

3 40 50 70 35 67

4 45 15 35 30 32

5 77 47 67 32 64

1 2 3 4 5

1 2 2 3 2 2

2 1 4 4 4 4

3 1 4 4 4 4

4 2 2 3 2 5

5 4 4 4 4 4

D( 5 ) R( 5 )

These are the completed matrices. Are yours correct?

Page 45: Floyd’s Algorithm can be used to help solve Travelling Salesman

1

5

4

3

2

20 15 12

35

50

50

10

Qu2.

Answers…………….

Page 46: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 5 ) R( 5 )

These are the completed matrices. Are yours correct?

1 2 3 4 5

1 100 50 50 65 60

2 50 40 20 35 30

3 50 20 20 15 10

4 65 35 15 24 12

5 60 30 10 12 20

1 2 3 4 5

1 2 2 3 3 3

2 1 3 3 4 3

3 1 2 5 4 5

4 3 2 3 5 5

5 3 3 3 4 3

Page 47: Floyd’s Algorithm can be used to help solve Travelling Salesman

1

4

3

2

8

3 5

4

3

2

Qu2.

Answers…………….

Page 48: Floyd’s Algorithm can be used to help solve Travelling Salesman

D( 4 ) R( 4 )

These are the completed matrices. Are yours correct?

1 2 3 4

1 6 3 6 4

2 3 6 5 3

3 6 5 4 2

4 4 3 2 4

1 2 3 4

1 2 2 4 4

2 1 1 3 4

3 4 2 4 4

4 1 2 3 3