What’s the cheapest way to link five GAA grounds without paying for extra cables?
Five GAA grounds in Galway need to share a communications network. Each possible cable has a price, and the clubs want all five grounds linked. Can you pick the cables that give the lowest total cost?
The five dots are grounds, and the lines are possible cables. Each price is the weight of that cable. A tree is connected and has no cycles. A spanning tree includes every ground. The spanning tree with the lowest total cable cost is a minimum spanning tree.
Put every cable into one list, from cheapest to most expensive. A to B goes first at two thousand euro, followed by C to D at three thousand. Keep going until every candidate is listed. This sorted list is the starting point for Kruskal’s algorithm.
Try a fresh list. A to B costs eight thousand euro, B to C costs three thousand, and A to C costs six thousand. Pick the order in which you would consider the cables.
Follow the selected cables from B through A and C to D. The dashed cable from B to D would close that path into a cycle. For each candidate in the sorted list, reject it if its ends already have a path between them. Otherwise, take it.
Take A to B, then C to D. Neither closes a cycle. A to C joins the two groups. Reject B to D: its ends are already linked. Take D to E. All five sites are now connected, so stop before testing C to E. The total is fifteen thousand euro.
Try a four-site network. A to B has weight one, A to C has weight two, B to C has weight three, and C to D has weight five. Pick the rejected cable and the total weight of the tree.
After taking A to B, you might think the next cable has to touch A or B. That would make you skip C to D and jump to A to C. Take C to D when it comes up. It creates no cycle, and the two groups can join later.
Prim’s algorithm starts at one site, here A. At each step, pick the cheapest cable with one end in your tree and one end outside it. Take A to B, then A to C, then C to D. Finally, D to E brings the last site into your tree.