Title: MINIMAL CONNECTOR PROBLEMS
1MINIMAL CONNECTOR PROBLEMS
Problem A cable TV company is installing a
system of cables to connect all the towns in a
region. The numbers in the network show
distances in miles.
2(No Transcript)
3KRUSKALS ALGORITHM
Step 1 Rank the arcs in ascending order of weight
Step 2 Select the arc of least weight and use
this to start the tree
Step 3 Choose the next smallest arc and add this
to the tree UNLESS IT COMPLETES A CYCLE in which
case reject it and proceed to the next smallest
arc
Step 4 Repeat Step 3 until all vertices
are included in the tree
4Smallest arc
Next smallest arc
FE (8)
DB (12)
BC (13)
AB (19)
FD (10)
Not DE because it produces a cycle
Not EC or DC as they produce cycles
A
List the arcs as you choose them
19
D
12
FE
FD
DB
BC
AB
B
10
13
You now have a minimal spanning tree
C
F
E
8
Total Length 62
5PRIMS ALGORITHM
Step 1 Choose a starting vertex
Step 2 Connect it to the nearest vertex using
the least arc
Step 3 Connect the nearest vertex not in the
tree, to the tree, using the least arc
Step 4 Repeat step 3 until all of the vertices
are connected
6Arcs from A, B, D, E F have lengths 13, 15 and
14
Arcs from A, B, D F have lengths 13, 15 and 8
Arcs from A and B have lengths 20, 12 and 13
Arcs from A, B D have lengths 13, 15, 12 and 10
Start with vertex A
Nearest is B so add AB
So choose FE (8)
So choose BD (12)
So choose DF (10)
So choose BC (13)
A
19
List the arcs as you choose them
D
B
12
AB
BD
DF
FE
BC
10
13
F
C
E
8
You now have a minimal spanning tree
Total Length 62
7Both algorithms have led to the same minimal
spanning tree
But the order of choosing the arcs is different
Kruskal gives
FE, FD, DB, BC, AB
Prim gives
AB, BD, DF, FE, BC
That is why it is important to write down the
arcs as you select them so that the examiner can
tell whether or not you have used the correct
algorithm