Presentation is loading. Please wait.

Presentation is loading. Please wait.

MINIMAL 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.

Similar presentations


Presentation on theme: "MINIMAL 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."— Presentation transcript:

1 MINIMAL 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

3 KRUSKAL’S ALGORITHM Step 1Rank the arcs in ascending order of weight Step 2Select the arc of least weight and use this to start the tree Step 3Choose 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 4Repeat Step 3 until all vertices are included in the tree

4 Smallest arc: FE (8) FE8 List the arcs as you choose them FE Next smallest arc: FD (10) D 10 FD DB (12) B 12 DB Not DE because it produces a cycle BC (13) C 13 BC AB (19) A 19 AB Not EC or DC as they produce cycles You now have a minimal spanning tree Total Length = 62

5 PRIM’S ALGORITHM Step 1Choose a starting vertex Step 2Connect it to the nearest vertex using the least arc Step 3Connect the nearest vertex not in the tree, to the tree, using the least arc Step 4Repeat step 3 until all of the vertices are connected

6 Start with vertex A Nearest is B so add AB A B 19 Arcs from A and B have lengths 20, 12 and 13 So choose BD (12) List the arcs as you choose them AB D 12 BD Arcs from A, B & D have lengths 13, 15, 12 and 10 So choose DF (10) F 10 DF Arcs from A, B, D, E & F have lengths 13, 15 and 14 So choose FE (8) E8 FE So choose BC (13) Arcs from A, B, D & F have lengths 13, 15 and 8 C 13 BC You now have a minimal spanning tree Total Length = 62

7 Both 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


Download ppt "MINIMAL 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."

Similar presentations


Ads by Google