A spanning tree is a tree that contains every vertex of a connected graph.
It keeps the vertex set of the graph but selects only enough edges to preserve connectivity. In this sense, a spanning tree is a cycle-free skeleton of a connected graph. It removes redundancy while keeping all vertices reachable.
Spanning trees are central in graph theory because they connect trees with general connected graphs. They are also central in algorithms, where one often wants a minimal connected structure inside a larger network.
30.1 Definition
Let
be a connected undirected graph.
A spanning tree of is a subgraph
such that
and is a tree.
The word spanning means that contains all vertices of . Only the edge set is reduced.
If has vertices, then every spanning tree of has exactly
edges.
30.2 Example
Consider the graph
with edge set
This graph is connected and contains cycles.
One spanning tree is obtained by choosing
The resulting subgraph contains all four vertices and has no cycle. It is a path on four vertices, so it is a tree.
Another spanning tree is
A connected graph may have many different spanning trees.
30.3 Existence of Spanning Trees
Every finite connected graph has a spanning tree.
Theorem 30.1
If is a finite connected graph, then has a spanning tree.
Proof
If contains no cycle, then is already a tree. Since it is connected and contains all its vertices, it is a spanning tree of itself.
Suppose contains a cycle. Choose one edge from the cycle and remove it. The graph remains connected, because the two endpoints of the removed edge are still connected by the rest of the cycle.
If the resulting graph still contains a cycle, repeat the process.
Since is finite, this process must stop. The final graph is connected and acyclic. Therefore it is a tree. Since no vertices were removed, it is a spanning tree of .
30.4 Spanning Trees as Minimal Connected Subgraphs
A spanning tree is a minimal connected spanning subgraph.
This means that it connects all vertices, and removing any edge destroys that connectivity.
Theorem 30.2
Let be a spanning tree of a connected graph . Then removing any edge from disconnects .
Proof
Since is a tree, every edge of is a bridge. Removing any edge from a tree disconnects it.
Thus a spanning tree contains no unnecessary edge for connectivity.
The theorem also explains why spanning trees are used as minimal network designs. Every selected edge is needed.
30.5 Spanning Trees and Cycles
A spanning tree removes exactly enough edges to eliminate all cycles.
Let be a connected graph with vertices and edges. A spanning tree has edges. Therefore one must remove
edges from to obtain a spanning tree.
The number
is called the cycle rank, cyclomatic number, or circuit rank of a connected graph.
It measures the number of independent cycles in the graph.
30.6 Characterization by Edge Count
A connected spanning subgraph is a spanning tree exactly when it has the smallest possible number of edges.
Theorem 30.3
Let be a connected graph with vertices. If is a connected spanning subgraph of , then
Equality holds if and only if is a spanning tree.
Proof
Since is connected and has vertices, it contains a spanning tree. Every spanning tree on vertices has edges. Therefore
If equality holds, then has exactly edges. A connected graph with edges is a tree. Hence is a spanning tree.
Conversely, if is a spanning tree, then it has exactly edges.
30.7 Building Spanning Trees by Search
Graph traversal algorithms naturally produce spanning trees.
Breadth-First Search Tree
If breadth-first search starts at a vertex in a connected graph, then each newly discovered vertex records the edge by which it was first reached.
These discovery edges form a spanning tree called a BFS tree.
A BFS tree has an additional distance property. For every vertex , the distance from to in the BFS tree equals the shortest-path distance from to in the original unweighted graph.
Depth-First Search Tree
Depth-first search also records discovery edges. These edges form a DFS tree.
A DFS tree records the recursive exploration structure of the graph. It is useful for detecting cycles, finding articulation points, computing connected components, and constructing topological orderings in directed graphs.
Both BFS and DFS show that spanning trees are constructive objects. They can be built systematically.
30.8 Spanning Forests in Disconnected Graphs
A disconnected graph has no spanning tree, because no connected subgraph can contain all vertices.
Instead, one uses a spanning forest.
A spanning forest contains every vertex and includes one spanning tree for each connected component.
If a graph has connected components
then a spanning forest consists of spanning trees
where spans .
If the graph has vertices and components, then every spanning forest has
edges.
30.9 Counting Spanning Trees
A connected graph may have many spanning trees.
For the complete graph , Cayley’s formula gives the number of spanning trees:
For example:
| Graph | Number of spanning trees |
|---|---|
More generally, the number of spanning trees of a graph can be computed using the Matrix-Tree Theorem, which uses the graph Laplacian.
This connects spanning trees with linear algebra and spectral graph theory.
30.10 Edge Exchange Property
Spanning trees satisfy an important exchange principle.
Theorem 30.4
Let be a spanning tree of a connected graph , and let be an edge of not in . Then contains exactly one cycle. If is any edge on that cycle, then
is a spanning tree, provided lies on the cycle.
Proof
Since is a tree, adding the edge creates exactly one cycle.
If an edge on this cycle is removed, the cycle is broken. The graph remains connected, because the endpoints formerly joined through are still connected by the rest of the cycle.
The resulting graph is connected, spans all vertices, and has edges. Therefore it is a spanning tree.
This exchange property is fundamental in the theory of graphic matroids and minimum spanning tree algorithms.
30.11 Minimum Spanning Trees
If the edges of have weights, then a natural problem is to find a spanning tree of minimum total weight.
Let
assign a weight to each edge.
The weight of a spanning tree is
A minimum spanning tree is a spanning tree such that
for every spanning tree of .
Minimum spanning trees are used in network design, clustering, circuit layout, approximation algorithms, and image segmentation.
The next chapter studies them in detail.
30.12 Applications
Spanning trees appear whenever a connected structure must be reduced to a minimal connected backbone.
| Application | Role of spanning tree |
|---|---|
| Communication network | Connect all nodes with minimal links |
| Electrical network | Analyze independent branches |
| Routing | Build loop-free forwarding structure |
| Clustering | Remove high-weight edges from an MST |
| Distributed systems | Broadcast over a tree topology |
| Graph algorithms | Organize traversal and recursion |
| Approximation algorithms | Use tree structure as a simplified model |
The main advantage is structural simplicity. A spanning tree preserves reachability but removes all cycles.
30.13 Summary
A spanning tree of a connected graph is a tree that contains every vertex of the graph.
Every finite connected graph has at least one spanning tree. If the graph has vertices, each spanning tree has exactly edges.
Spanning trees are minimal connected spanning subgraphs. Removing any selected edge disconnects them. Adding any unused edge creates exactly one cycle.
They form a bridge between general graphs and trees. This makes them useful both theoretically and algorithmically, especially in traversal, optimization, network design, and graph decomposition.