LOGBOOK

HELP

Quiz Entry - updated: 2026.11.27

What is a spanning tree, why is it usually not unique, and what is it used for?

A spanning tree of a connected graph is a spanning subgraph that is a tree: it keeps all $n$ vertices and exactly $n - 1$ of the edges, just enough to connect them without a cycle. A graph usually has many spanning trees; only a graph that is itself a tree has exactly one. A graph that is not connected has a spanning forest instead, one spanning tree per component.

A graph G with 8 edges, two of its spanning trees with 4 edges each, and a spanning forest of a graph with two components

* Both spanning trees reach all five vertices with four edges; they just use different ones. *

Not unique because there are usually many ways to drop edges until no cycle is left: the graph G in the picture has 40 different spanning trees, and a complete graph on $n$ vertices has $n^{n-2}$ (Cayley's formula), 16 for four vertices. A tree has nothing to drop, so it is its own and only spanning tree.

Spanning trees appear wherever a network must reach everything with as few links as possible and without loops. Ethernet switches, for example, run a spanning tree protocol: of the redundant cables between them, only those of one spanning tree carry traffic, so frames cannot circle forever, and when a cable fails another spanning tree is chosen. With costs on the edges, the cheapest such tree is a minimum spanning tree. Reducing a graph to a spanning tree is also a common simplification in its own right: a file system with links between its directories is a graph, and the directory tree that ignores the links spans all the same folders.

Go deeper:

  • doc Spanning tree — definitions, counting spanning trees, and their uses in networks and algorithms.
  • doc Spanning Tree Protocol — how Ethernet switches keep a loop-free spanning tree and recover from link failures.

From Quiz: ADS / Graphs: Basics, Representations and Spanning Trees | Updated: Nov 27, 2026