D( 0 )

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.
page 1
To look back at the network click here:
D( 0 )
A
R( 0 )
M
L
23
10

10
48
19
A

M
23

L
10
10

48
19

7
20
B

X
18

A
M
L
B
X

A
1
2
3
4
5
M
1
2
3
4
5
7
L
1
2
3
4
5
20
B
1
2
3
4
5
X
1
2
3
4
5
B
X
18

This is the route matrix.
It will eventually show the
next vertex that needs to be
taken on route to finding the
shortest route to another vertex.
This is the distance matrix.
It initially shows the direct
distance between one vertex
and the others. The infinity sign
denotes no direct route.
•To view the process step by step click here
•To view the completed matrices click here
page 2
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.
D( 0 )
A
R( 0 )
M
L
B
23
10

10
48
19
A

M
23

L
10
10

48
19

7
20
B

X
18

A
M
L
B
X

A
1
2
3
4
5
M
1
2
3
4
5
7
L
1
2
3
4
5
20
B
1
2
3
4
5
X
1
2
3
4
5
X
18

Click here to see step:
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.
D( 0 )
A
R( 0 )
M
L
B
23
10

10
48
19
A

M
23

L
10
10

48
19

7
20
B

X
18

23 + 23 = 46, less than
change.
A
M
L
B
X

A
1
2
3
4
5
M
1
2
3
4
5
7
L
1
2
3
4
5
20
B
1
2
3
4
5
X
1
2
3
4
5
X
18

 so
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
A
M
L
B
X
A
1
2
3
4
5
X
A

23
10

M
23
46
10

M
1
2
3
4
5
L
10
10

48
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18

23 + 23 = 46, less than
change.
18

 so
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
A
M
L
B
X
A
1
2
3
4
5
X
A

23
10

M
23
46
10

M
1
2
3
4
5
L
10
10

48
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18

18

10 + 23 = 33, so we leave this
item
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
A
M
L
B
X
A
1
2
3
4
5
X
A

23
10

M
23
46
10

M
1
2
3
4
5
L
10
10

48
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18

18

When  is involved we leave
the item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
A
M
L
B
X
A
1
2
3
4
5
X
A

23
10

M
23
46
10

M
1
2
3
4
5
L
10
10

48
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18

18

18 + 23 = 41, so we replace the
item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
C
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
41
M
1
2
3
4
5
L
10
10

48
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


18 + 23 = 41, so we replace the
item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
C
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
19
7
L
1
2
3
4
5
B
1
2
3
4
5
X
1
2
3
4
5
B

X
18
48


19 48
7
41 20
20

23 + 10 = 33, so we leave this
item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


10 + 10 = 20, so we replace this
item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


Infinity is involved so we leave
this item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


18 + 10 = 28 which is more than
7 so we leave this item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


Infinity is involved so we leave
this item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


Infinity is involved so we leave
this item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


Infinity is involved so we leave
this item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


Infinity is involved so we leave
this item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
7
20
X
1
2
3
4
5
B

X
18


We replace this item with
23 + 18 = 41
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
X
1
2
3
4
5
B

X
18

We replace this item with
23 + 18 = 41
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
X
1
2
3
4
5
B

X
18

10 + 18 = 28, 7 is less than this
so leave it.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
X
1
2
3
4
5
B

X
18

Infinity is involved so leave this
item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
X
1
2
3
4
5
B

X
18

18 + 18 = 36, so replace this
item.
Click here to see step:
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.
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
2
3
4
5
B

X
18
18 + 18 = 36, so replace this
item.
Click here to see step:
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
2
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
2
3
4
5
B

X
18
Click here to see step:
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
1
3
4
5
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
2
3
4
5
B

X
18
Click here to see step:
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
1
3
4
1
L
10
10
20
19
L
1
2
3
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
2
3
4
5
B

X
18
Click here to see step:
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
1
3
4
1
L
10
10
20
19
L
1
2
1
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
2
3
4
5
B

X
18
Click here to see step:
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
1
3
4
1
L
10
10
20
19
L
1
2
1
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
1
3
4
5
B

X
18
Click here to see step:
D( 0 )
A
M
L
R( 0 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
1
3
4
1
L
10
10
20
19
L
1
2
1
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
1
3
4
1
B

X
18
Click here to see step:
We have now completed one iteration. We rename the new matrices:
D( 1 )
A
M
L
R( 1 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
1
3
4
1
L
10
10
20
19
L
1
2
1
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
1
3
4
1
B

X
18
Subsequent iterations are now shown completed:
Click here to see step:
Click here to see final matrices:
D( 1 )
A
M
L
R( 1 )
B
X
A
M
L
B
X
A

23
10

18
A
1
2
3
4
5
M
23
46
10
48
41
M
1
1
3
4
1
L
10
10
20
19
L
1
2
1
4
5
48
19

7
20
B
1
2
3
4
5
41
7
20
36
X
1
1
3
4
1
B

X
18
Subsequent iterations are now shown completed:
Click here to see step:
Click here to see final matrices:
The items have been altered accordingly:
D( 1 )
R( 1 )
A
M
L
B
X
A
1
2
3
4
5
41
M
1
1
3
4
1
19
7
L
1
2
1
4
5
19
96
20
B
1
2
3
4
5
7
20
36
X
1
1
3
4
1
A
M
L
B
X
A
46
23
10
71
18
M
23
46
10
48
L
10
10
20
B
71
48
X
18
41
Subsequent iterations are now shown completed:
Click here to see step:
Click here to see final matrices:
We can now rename the matrices:
D( 2 )
R( 2 )
A
M
L
B
X
A
2
2
3
2
5
41
M
1
1
3
4
1
19
7
L
1
2
1
4
5
19
96
20
B
2
2
3
2
5
7
20
36
X
1
1
3
4
1
A
M
L
B
X
A
46
23
10
71
18
M
23
46
10
48
L
10
10
20
B
71
48
X
18
41
Click here to see step:
Click here to see final matrices:
Next iteration:
D( 2 )
R( 2 )
A
M
L
B
X
A
2
2
3
2
5
41
M
1
1
3
4
1
19
7
L
1
2
1
4
5
19
96
20
B
2
2
3
2
5
7
20
36
X
1
1
3
4
1
A
M
L
B
X
A
46
23
10
71
18
M
23
46
10
48
L
10
10
20
B
71
48
X
18
41
Click here to see step:
Click here to see final matrices:
Next iteration, the items are altered appropriately :
D( 2 )
R( 2 )
A
M
L
B
X
A
3
3
3
3
3
17
M
3
3
3
3
3
19
7
L
1
2
1
4
5
19
38
20
B
3
3
3
3
5
7
20
14
X
3
3
3
4
3
A
M
L
B
X
A
20
20
10
29
17
M
20
20
10
29
L
10
10
20
B
29
29
X
17
17
Click here to see step:
Click here to see final matrices:
The matrices are renamed :
D( 3 )
R( 3 )
A
M
L
B
X
A
3
3
3
3
3
17
M
3
3
3
3
3
19
7
L
1
2
1
4
5
19
38
20
B
3
3
3
3
5
7
20
14
X
3
3
3
4
3
A
M
L
B
X
A
20
20
10
29
17
M
20
20
10
29
L
10
10
20
B
29
29
X
17
17
Click here to see step:
Click here to see final matrices:
The next iteration :
D( 3 )
R( 3 )
A
M
L
B
X
A
3
3
3
3
3
17
M
3
3
3
3
3
19
7
L
1
2
1
4
5
19
38
20
B
3
3
3
3
5
7
20
14
X
3
3
3
4
3
A
M
L
B
X
A
20
20
10
29
17
M
20
20
10
29
L
10
10
20
B
29
29
X
17
17
Click here to see step:
Click here to see final matrices:
In this iteration, you do not need to change any of the items, so we go
onto the next iteration :
D( 3 )
R( 3 )
A
M
L
B
X
A
3
3
3
3
3
17
M
3
3
3
3
3
19
7
L
1
2
1
4
5
19
38
20
B
3
3
3
3
5
7
20
14
X
3
3
3
4
3
A
M
L
B
X
A
20
20
10
29
17
M
20
20
10
29
L
10
10
20
B
29
29
X
17
17
Click here to see step:
Click here to see final matrices:
D( 4 )
R( 4 )
A
M
L
B
X
A
3
3
3
3
3
17
M
3
3
3
3
3
19
7
L
1
2
1
4
5
19
38
20
B
3
3
3
3
5
7
20
14
X
3
3
3
4
3
A
M
L
B
X
A
20
20
10
29
17
M
20
20
10
29
L
10
10
20
B
29
29
X
17
17
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
3
3
3
3
3
17
M
3
3
3
3
3
19
7
L
1
2
1
4
5
19
38
20
B
3
3
3
3
5
7
20
14
X
3
3
3
4
3
A
M
L
B
X
A
20
20
10
29
17
M
20
20
10
29
L
10
10
14
B
29
29
X
17
17
Click here to see step:
Click here to see final matrices:
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:
D( 5 )
R( 5 )
A
M
L
B
X
A
3
3
3
3
3
17
M
3
3
3
3
3
19
7
L
1
2
5
4
5
19
38
20
B
3
3
3
3
5
7
20
14
X
3
3
3
4
3
A
M
L
B
X
A
20
20
10
29
17
M
20
20
10
29
L
10
10
14
B
29
29
X
17
17
Click here to see new network:
29
17
M
29
B
19
10
20
20
L
10
7
17
A
X
This network now gives you a better idea of the quickest routes.
The route matrix gives us an idea about the next vertex to visit on route 1 represents A, 2 - M, etc.
Click below to try a question:
page 1
4
2
15
32
30
35
75
5
1
70
40
3
Try this one! Click below when you have completed it to
check the answers:
These are the completed matrices. Are yours correct?
D( 5 )
R( 5 )
1
2
3
4
5
1
2
3
4
5
1
60
30
40
45
77
1
2
2
3
2
2
2
30
30
50
15
47
2
1
4
4
4
4
3
40
50
70
35
67
3
1
4
4
4
4
4
45
15
35
30
32
4
2
2
3
2
5
5
77
47
67
32
64
5
4
4
4
4
4
Qu2.
2
4
35
50
15
20
12
1
10
50
5
3
Answers…………….
These are the completed matrices. Are yours correct?
D( 5 )
R( 5 )
1
2
3
4
5
1
2
2
3
3
3
30
2
1
3
3
4
3
15
10
3
1
2
5
4
5
15
24
12
4
3
2
3
5
5
10
12
20
5
3
3
3
4
3
1
2
3
4
5
1
100
50
50
65
60
2
50
40
20
35
3
50
20
20
4
65
35
5
60
30
Qu2.
2
3
5
3
3
1
8
2
4
4
Answers…………….
These are the completed matrices. Are yours correct?
D( 4 )
R( 4 )
1
2
3
4
1
2
3
4
1
6
3
6
4
1
2
2
4
4
2
3
6
5
3
2
1
1
3
4
3
6
5
4
2
3
4
2
4
4
4
4
3
2
4
4
1
2
3
3