Trees and spanning trees
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.
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.
For a tree with \(n\) vertices:
Each edge adds \(2\) to the degree sum, so:
For a connected graph with \(n\) vertices and \(e\) edges:
How to check whether some edges form a spanning tree
- Count. There must be exactly \(n - 1\) edges for \(n\) vertices.
- Reach. Every vertex must be touched by a chosen edge, and you must be able to travel between any two vertices on chosen edges.
- 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
- Work out how many edges must be removed: \(e - (n - 1)\).
- 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.
- Multiply the choices within a case and add the cases. Check small cases by drawing them.
Use \(n - 1\), then test the red edges for reach and cycles.
| \(\text{edges in a spanning tree}\) | \(=\) | \(7 - 1\) |
| \(\) | \(=\) | \(6\) |
| \(\text{edges removed}\) | \(=\) | \(10 - 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.
Use \(n - 1\) edges and the degree sum.
| \(\text{edges}\) | \(=\) | \(12 - 1\) |
| \(\) | \(=\) | \(11\) |
| \(\text{sum of degrees}\) | \(=\) | \(2 \times 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.
\(6\) vertices and \(7\) edges, so \(7 - 5 = 2\) edges are removed. The two squares share the edge \(BE\).
| \(\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\) |
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).
A plan that keeps every station connected with the fewest channels is a spanning tree.
| \(\text{kept}\) | \(=\) | \(7 - 1\) |
| \(\) | \(=\) | \(6\) |
| \(\text{closed}\) | \(=\) | \(9 - 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
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.