Resources For Teachers For Tutors For Students & Parents AI New Books Pricing
Year 12 Maths - General (Unit 3 & Unit 4) Trees, minimum connectors and shortest paths

Trees and spanning trees

20 practice questions 0 video lessons Theory + worked examples

Discover trees and spanning trees in Year 12 VCE General Mathematics. A tree is a network with no cycles, so there is exactly one route between any two points, like a family tree or the irrigation channels branching out across a Mildura farm. Engineers use trees whenever every site must be connected with no wasted links.

You will learn why a tree with \(n\) vertices always has \(n - 1\) edges, check whether a set of edges forms a spanning tree, and count the spanning trees of small graphs, including cycles. You will see why a bridge must stay in every spanning tree, ready to find the cheapest spanning tree with Prim’s algorithm next.

Create a free accountTrack your progress and save your work as you go.
Create free account

Theory

A tree is a connected graph with no cycles, and a spanning tree connects every vertex of a graph with the fewest possible edges. This Year 12 General Mathematics guide for students in Victoria explains the \(n - 1\) rule, how to test for a spanning tree, why bridges always stay, and how to count the spanning trees of a small graph.

A tree is a connected graph with no cycles. There is exactly one path between any two of its vertices, so every edge of a tree is a bridge: remove any edge and the tree falls into two pieces. A tree with \(n\) vertices always has exactly \(n - 1\) edges. Adding one more edge to a tree always creates exactly one cycle.

A spanning tree of a connected graph is a tree that uses every vertex of the graph and only edges that are already in the graph. It is the graph trimmed down to the fewest edges that still connect everything. A graph usually has many different spanning trees.

To get a spanning tree, remove edges one at a time, each time breaking a cycle, until no cycles are left. You can never remove a bridge of the graph, so a bridge is in every spanning tree.

Key idea. A graph with \(n\) vertices and \(e\) edges has spanning trees with exactly \(n - 1\) edges, so \(e - (n - 1)\) edges must be removed. Any \(n - 1\) edges that connect all the vertices form a spanning tree.
A spanning tree of a graphGraph with six vertices and nine edges. Five red edges AF, BF, BC, CE and DE form a spanning tree; the other four edges are grey. A B C D E F
The red edges reach all \(6\) vertices, contain no cycle and number \(6 - 1 = 5\): a spanning tree. The \(9 - 5 = 4\) grey edges were removed.
The four spanning trees of a cycle of four verticesSquare A B C D drawn four times; each time one edge is dashed grey (left out) and the other three red edges form a spanning tree. A B C D A B C D A B C D A B C D
A cycle of \(4\) vertices has \(4\) spanning trees: leave out any one of its \(4\) edges. In the same way a cycle of \(n\) vertices has \(n\) spanning trees.

For a tree with \(n\) vertices:

\[\text{number of edges} = n - 1\]
e=n−1

Each edge adds \(2\) to the degree sum, so:

\[\text{sum of degrees of a tree} = 2(n - 1)\]
∑deg=2(n−1)

For a connected graph with \(n\) vertices and \(e\) edges:

\[\text{edges removed to make a spanning tree} = e - (n - 1)\]
e−(n−1)
Quick test for a tree. A graph is a tree if it is connected and has exactly one fewer edge than vertices. If it has more edges, it contains a cycle; if fewer, it is not connected.

How to check whether some edges form a spanning tree

  1. Count. There must be exactly \(n - 1\) edges for \(n\) vertices.
  2. Reach. Every vertex must be touched by a chosen edge, and you must be able to travel between any two vertices on chosen edges.
  3. No cycles. Look for a closed loop of chosen edges. If there is one, it is not a tree.

How to count the spanning trees of a small graph

  1. Work out how many edges must be removed: \(e - (n - 1)\).
  2. Each removal must break a cycle, so choose one edge to remove from each cycle. If two cycles share an edge, split into cases: keep the shared edge, or remove it.
  3. Multiply the choices within a case and add the cases. Check small cases by drawing them.
Example 1 β€” Is it a spanning tree?
The graph has \(7\) vertices and \(10\) edges. (i) How many edges does a spanning tree have, and how many edges are removed? (ii) Do the red edges form a spanning tree?
Solution

Use \(n - 1\), then test the red edges for reach and cycles.

Example 1 graphSeven vertices A to G and ten edges. Red edges chosen: AB, BC, CG, BG, DE, EF. A B C D E F G
\(\text{edges in a spanning tree}\)\(=\)\(7 - 1\)
\(\)\(=\)\(6\)
\(\text{edges removed}\)\(=\)\(10 - 6\)
\(\)\(=\)\(4\)
6,4

(i) \(6\) edges, so \(4\) are removed. (ii) No. There are \(6\) red edges touching all \(7\) vertices, but \(B\)–\(C\)–\(G\)–\(B\) is a cycle, and \(\{D, E, F\}\) is cut off from \(\{A, B, C, G\}\). Swapping \(BG\) for \(FG\) gives a spanning tree.

Example 2 β€” Facts about a tree
A tree has \(12\) vertices. (i) How many edges does it have? (ii) What is the sum of the degrees of its vertices? (iii) What happens if one more edge is added between two of its vertices?
Solution

Use \(n - 1\) edges and the degree sum.

\(\text{edges}\)\(=\)\(12 - 1\)
\(\)\(=\)\(11\)
\(\text{sum of degrees}\)\(=\)\(2 \times 11\)
\(\)\(=\)\(22\)
11,22

(i) \(11\) edges. (ii) \(22\). (iii) The graph would have \(12\) edges, one more than a tree on \(12\) vertices can have, so it now contains exactly one cycle and is no longer a tree.

Example 3 β€” Counting spanning trees
How many different spanning trees does the graph shown have?
Solution

\(6\) vertices and \(7\) edges, so \(7 - 5 = 2\) edges are removed. The two squares share the edge \(BE\).

Example 3 graphTwo squares A B E F and B C D E sharing the edge B E. A B C D E F
\(\text{keep } BE\)\(:\)\(\text{remove 1 of 3 from each square}\)
\(\)\(=\)\(3 \times 3 = 9\)
\(\text{remove } BE\)\(:\)\(\text{remove 1 more from the outer cycle of 6}\)
\(\)\(=\)\(6\)
\(\text{total}\)\(=\)\(9 + 6\)
\(\)\(=\)\(15\)
15

If \(BE\) stays, one of the other three edges of each square must go: \(3 \times 3 = 9\) ways. If \(BE\) is removed, the rest is the cycle \(A\)–\(B\)–\(C\)–\(D\)–\(E\)–\(F\)–\(A\), and any one of its \(6\) edges can go. The graph has 15 spanning trees (checked by listing them all).

Example 4 β€” A channel that must stay
The graph shows irrigation channels between pump stations near Mildura. The council wants to keep as few channels as possible while every station stays connected. (i) How many channels are kept, and how many closed? (ii) Which channel must be kept in every plan? Why?
Solution

A plan that keeps every station connected with the fewest channels is a spanning tree.

Irrigation channels between pump stationsPump stations P, Q, R, S on the left joined by PQ, PR, QR, QS, RS; the channel ST; triangle T, U, V. P Q R S T U V
\(\text{kept}\)\(=\)\(7 - 1\)
\(\)\(=\)\(6\)
\(\text{closed}\)\(=\)\(9 - 6\)
\(\)\(=\)\(3\)
6,3

(i) \(6\) channels are kept and \(3\) closed. (ii) \(ST\). It is a bridge: it is on no cycle, and closing it would cut \(T\), \(U\) and \(V\) off from \(P\), \(Q\), \(R\) and \(S\). So it is in every spanning tree.

Common pitfalls

\(n - 1\) edges is not enough on its own. Edges can number \(n - 1\) and still contain a cycle while leaving some vertices cut off. Check for cycles and reach as well.
Use only the graph’s edges. A spanning tree may only use edges that are already in the graph. Adding a new edge does not give a spanning tree of that graph.
Every vertex. A tree that misses a vertex is not a spanning tree, even if it has no cycles.

Frequently asked questions

What is a tree in graph theory?

A tree is a connected graph with no cycles. There is exactly one path between any two vertices, and a tree with n vertices has n - 1 edges.

What is a spanning tree?

A spanning tree of a connected graph is a tree that includes every vertex of the graph and uses only edges from the graph. It connects everything with the fewest possible edges.

How many edges does a spanning tree have?

One fewer than the number of vertices. A graph with 8 vertices has spanning trees with 7 edges, whatever the number of edges in the original graph.

How many spanning trees does a cycle have?

A cycle with n vertices has n spanning trees, because leaving out any one of its n edges leaves a path through every vertex.

Why is a bridge in every spanning tree?

Removing a bridge would disconnect the graph, so no spanning tree can leave it out. Only edges on cycles can be removed.