Resources For Teachers For Tutors For Students & Parents AI New Books Pricing
Year 11 (2026) Maths Standard (2026) Networks, Paths and Trees

Minimal Spanning Trees and Connector Problems

20 practice questions 8 video lessons Theory + worked examples
Practice 20 questions
Practice questions

Every question with a fully worked solution.

Start practising
Watch 8 video(s)
  • Minimal Spanning Trees and Connector Problems - Video - Minimum Spanning Trees 1 Watch
  • Minimal Spanning Trees and Connector Problems - Video - Minimum Spanning Trees 2 Watch
  • Minimal Spanning Trees and Connector Problems - Video - Minimum Spanning Trees 3 Watch
  • Minimal Spanning Trees and Connector Problems - Video - Minimum Spanning Trees 4 Watch
  • Minimal Spanning Trees and Connector Problems - Video - Minimum Spanning Trees 5 Watch
  • Minimal Spanning Trees and Connector Problems - Video - Minimum Spanning Trees 6 Watch
  • Minimal Spanning Trees and Connector Problems - Video - Minimum Spanning Trees 7 Watch
  • Minimal Spanning Trees and Connector Problems - Video - Connector Problems Watch
Create a free accountTrack your progress and save your work as you go.
Create free account

Theory

A minimum spanning tree joins every vertex of a weighted network at the least total length or cost. This Year 11 Mathematics Standard page shows how to find one with Kruskal's algorithm and Prim's algorithm, from a diagram, a list or a table, and how to solve connector problems such as laying cable or pipes, including costs and edges that must be included.

A connector problem asks you to join every place in a network as cheaply as possible: laying fibre cable between towns, power to buildings or water pipes to farms. You do not need every possible link, only enough to connect every place, with no wasted loops.

A spanning tree is a tree that includes every vertex of the network: it is connected and has no closed loops (cycles). A spanning tree for a network with \(n\) vertices always has \(n-1\) edges. The minimum spanning tree is the spanning tree with the smallest total weight (length, time or cost).

Two step-by-step methods find it. Kruskal's algorithm takes the edges from shortest to longest, skipping any edge that would make a closed loop. Prim's algorithm starts at one vertex and grows a single tree, each time adding the cheapest edge from the tree to a new vertex. Both give the same total weight.

The weights can also be given in a table. The number in row \(A\), column \(B\) is the weight of edge \(AB\), and a dash means there is no direct link. Each edge appears twice (row \(A\) column \(B\), and row \(B\) column \(A\)), so use it only once.

A minimum spanning treeNetwork with vertices A to F. Edges: AB 6, BC 5, AD 4, BE 3, CF 7, DE 8, EF 2, AE 9, BF 6. The minimum spanning tree EF, BE, AD, BC, AB is highlighted in orange; the other edges are dashed. 6 5 4 3 7 8 2 9 6 A B C D E F
Kruskal's algorithm: \(EF=2\), \(BE=3\), \(AD=4\), \(BC=5\) and \(AB=6\) are added. \(BF=6\) is skipped because \(B\) and \(F\) are already joined through \(E\). Total \(=20\).
Prim's algorithm from AThe same network. Prim's algorithm starting at A adds AD 4 first, then AB 6, BE 3, EF 2 and BC 5. 6 (2nd) 5 (5th) 4 (1st) 3 (3rd) 7 8 2 (4th) 9 6 A B C D E F
Prim's algorithm from \(A\) grows one tree: \(AD\), then \(AB\), \(BE\), \(EF\) and \(BC\). The edges come in a different order, but the tree and the total (\(20\)) are the same.

For a network with \(n\) vertices:

\[\text{number of edges in a spanning tree}=n-1\]
number of edges in a spanning tree equals n minus 1
\[\text{length of the minimum spanning tree}=\text{total of the weights of its edges}\]
length of the minimum spanning tree equals the total of the weights of its edges

When the weights are lengths and you are given a price per metre or per kilometre:

\[\text{cost}=\text{total length}\times\text{cost per unit length}\]
cost equals total length times cost per unit length
AlgorithmStartEach step
Kruskal'sthe shortest edge in the networkadd the next shortest edge, unless it makes a closed loop
Prim'sthe vertex you are told to start atadd the cheapest edge joining the tree to a vertex not yet in the tree
Equal weights. If two edges have the same weight, take either one first. The total weight of the minimum spanning tree is the same.

Kruskal's algorithm

  1. List the edges from shortest to longest.
  2. Add the shortest edge, then the next shortest, writing “add” beside each one.
  3. Skip any edge whose two ends are already joined by edges you have added: it would make a closed loop.
  4. Stop when you have \(n-1\) edges (every vertex is joined), then add up the weights.

Prim's algorithm

  1. Start at the vertex you are given.
  2. List every edge from a vertex already in the tree to a vertex not yet in the tree, and add the cheapest.
  3. Repeat until every vertex is in the tree, then add up the weights.

Special cases

  1. An edge that must be included (for example, a pipe that is already built): put it in first, then use Kruskal's algorithm on the other edges.
  2. Is a given tree the minimum? Look for an edge that is not used. If adding it makes a loop that contains a longer edge, swap them: the tree was not the minimum.
  3. Cost: multiply the total length by the cost per metre or kilometre.
Example 1 — Kruskal's algorithm
Use Kruskal's algorithm to find the length of the minimum spanning tree for this network.
Weighted network for Example 1Edges AB 7, AC 4, BC 6, BD 3, CD 5, CE 8, DE 9. 7 4 6 3 5 8 9 A B C D E
Solution

Take the edges from shortest to longest, skipping any that would make a closed loop:

\(BD\)\(=\)\(3\quad\text{add}\)
\(AC\)\(=\)\(4\quad\text{add}\)
\(CD\)\(=\)\(5\quad\text{add}\)
\(BC\)\(=\)\(6\quad\text{skip (loop B-C-D)}\)
\(AB\)\(=\)\(7\quad\text{skip (loop)}\)
\(CE\)\(=\)\(8\quad\text{add}\)
BD 3 add, AC 4 add, CD 5 add, BC 6 skip, AB 7 skip, CE 8 add

There are 5 vertices, so the tree needs \(5-1=4\) edges. It now has 4, so \(DE=9\) is not needed.

\(\text{Total}\)\(=\)\(3+4+5+8\)
\(=\)\(20\)
total equals 3 plus 4 plus 5 plus 8 equals 20
Minimum spanning tree for Example 1Tree edges BD 3, AC 4, CD 5, CE 8 highlighted; AB 7, BC 6 and DE 9 dashed. 7 4 6 3 5 8 9 A B C D E

The minimum spanning tree has length \(\mathbf{20}\).

Example 2 — Prim's algorithm from a table
The table shows the cost, in thousands of dollars, of laying a water pipe directly between five farms. A dash means a pipe cannot be laid there.
\(P\)\(Q\)\(R\)\(S\)\(T\)
\(P\)–127–10
\(Q\)12–96–
\(R\)79–11–
\(S\)–611–8
\(T\)10––8–
Use Prim's algorithm, starting at farm \(P\), to find the order in which the pipes are chosen and the minimum total cost.
Solution

Grow the tree from \(P\), each time adding the cheapest edge from the tree to a new farm.

Step 1: edges from \(P\): \(PQ=12,\ PR=7,\ PT=10\). Add \(PR=7\).

Step 2: edges from \(\{P,R\}\): \(PQ=12,\ PT=10,\ RQ=9,\ RS=11\). Add \(QR=9\).

Step 3: edges from \(\{P,Q,R\}\): \(PT=10,\ QS=6,\ RS=11\). Add \(QS=6\).

Step 4: edges from \(\{P,Q,R,S\}\): \(PT=10,\ ST=8\). Add \(ST=8\).

All 5 farms are joined with \(5-1=4\) pipes.

\(\text{Total}\)\(=\)\(7+9+6+8\)
\(=\)\(30\)
total equals 7 plus 9 plus 6 plus 8 equals 30

The pipes are chosen in the order \(PR,\ QR,\ QS,\ ST\), and the minimum cost is \(30\) thousand dollars, which is \(\mathbf{\$30\,000}\).

Example 3 — Cost of connecting buildings
Data cable is to be laid between six buildings \(A\) to \(F\) at a sports centre. The possible trenches and their lengths, in metres, are:
\(AB=40,\ AC=25,\ BC=30,\ BD=35,\ CD=45,\)
\(CE=50,\ DE=20,\ DF=30,\ EF=25\)
Every building must be connected. Cable costs \(\$18\) per metre to lay. Find the minimum cost.
Solution

Use Kruskal's algorithm. \(AC\) and \(EF\) are both 25, and \(BC\) and \(DF\) are both 30: take either one first.

\(DE\)\(=\)\(20\quad\text{add}\)
\(AC\)\(=\)\(25\quad\text{add}\)
\(EF\)\(=\)\(25\quad\text{add}\)
\(BC\)\(=\)\(30\quad\text{add}\)
\(DF\)\(=\)\(30\quad\text{skip (loop D-E-F)}\)
\(BD\)\(=\)\(35\quad\text{add}\)
DE 20 add, AC 25 add, EF 25 add, BC 30 add, DF 30 skip, BD 35 add

That is \(6-1=5\) edges, so all 6 buildings are joined.

\(\text{Total}\)\(=\)\(20+25+25+30+35\)
\(=\)\(135\text{ m}\)
\(\text{Cost}\)\(=\)\(135\times 18\)
\(=\)\(\$2430\)
total equals 135 metres; cost equals 135 times 18 equals 2430 dollars
Cable trenches for Example 3Edges AB 40, AC 25, BC 30, BD 35, CD 45, CE 50, DE 20, DF 30, EF 25 (metres). The minimum spanning tree DE, AC, EF, BC, BD is highlighted. 40 25 30 35 45 50 20 30 25 A B C D E F

The minimum cost is \(\mathbf{\$2430}\).

Example 4 — Checking a tree and a fixed edge
The network shows the possible gas pipelines, in km, between five towns.
Possible pipelines for Example 4Edges AB 6, AD 8, BC 5, BD 4, CD 7, CE 9, DE 3, in kilometres. 6 8 5 4 7 9 3 A B C D E
(i) An engineer suggests the pipelines \(AB,\ BC,\ CD\) and \(DE\). Explain why this is not a minimum spanning tree.
(ii) The pipeline \(AD\) has already been built and must be part of the network. Find the minimum total length of pipeline, including \(AD\).
Solution

(i) The suggested tree has length \(6+5+7+3=21\) km. The pipeline \(BD=4\) is not used. Adding it makes the loop \(B\)-\(C\)-\(D\)-\(B\), which contains \(CD=7\). Swapping \(CD=7\) for \(BD=4\) still joins every town and is \(3\) km shorter (\(18\) km). So the suggested tree is not the minimum: \(D\) should join to \(B\) (weight 4), not to \(C\) (weight 7).

(ii) Start with \(AD=8\), then use Kruskal's algorithm on the other edges:

\(DE\)\(=\)\(3\quad\text{add}\)
\(BD\)\(=\)\(4\quad\text{add}\)
\(BC\)\(=\)\(5\quad\text{add}\)
\(AB\)\(=\)\(6\quad\text{skip (loop A-B-D)}\)
start with AD 8, then DE 3 add, BD 4 add, BC 5 add, AB 6 skip

All 5 towns are now joined with 4 edges.

\(\text{Total}\)\(=\)\(8+3+4+5\)
\(=\)\(20\text{ km}\)
total equals 8 plus 3 plus 4 plus 5 equals 20 kilometres

The minimum total length is \(\mathbf{20}\) km (2 km more than the minimum spanning tree, which uses \(AB=6\) instead of \(AD=8\)).

Common pitfalls

Stop at \(n-1\) edges. Once every vertex is joined, any further edge would make a loop. Five vertices need exactly four edges.
A loop is not always a triangle. Before adding an edge, check whether its two ends are already joined through edges you have chosen, however long the way round.
In Prim's algorithm, look from the whole tree. Compare the edges from every vertex already in the tree, not just the last one added, and only to vertices not yet in the tree.
Read a table carefully. A dash means there is no link (it is not a weight of 0), and each edge is listed twice, so count it once.
A minimum spanning tree is not a shortest path. It is the cheapest way to connect every vertex. The route between two particular vertices along the tree may be longer than the shortest path between them.

Frequently asked questions

What is a minimum spanning tree?

It is a set of edges that joins every vertex of a weighted network with no closed loops, and has the smallest possible total weight.

How many edges does a spanning tree have?

A spanning tree for a network with \(n\) vertices has \(n-1\) edges. For example, 10 towns need 9 links.

What is the difference between Kruskal's and Prim's algorithm?

Kruskal's algorithm takes edges from shortest to longest anywhere in the network, skipping any that make a loop. Prim's algorithm starts at one vertex and grows one tree, each time adding the cheapest edge to a new vertex. Both give the same total.

What happens if two edges have the same weight?

Take either one first. The tree you end up with may be different, but its total weight is the same.

What is a connector problem?

A practical problem where every place must be connected at the least total length or cost, such as laying cable, pipes or roads. It is solved by finding a minimum spanning tree.