Trees and spanning-tree structure
Relate unique routes, absence of cycles, and minimal connectivity, then isolate a spanning tree inside a larger graph.
On this page
The question for today
What you’ll understand
- Prove the unique-path characterization of a tree.
- Derive the edge count for a finite tree and forest.
- Explain how adding one edge to a tree creates a unique cycle.
A tree keeps every vertex connected using just enough edges. That minimality makes trees useful as communication backbones, search records, and proof structures. It also exposes a limitation: a minimal backbone contains no alternate route when an edge fails. We will connect these operational statements to exact equivalences about cycles, paths, and edge counts rather than relying on a tree-shaped drawing.
Connected and cycle-free
A tree is a finite, nonempty, connected simple undirected graph with no cycle. Between every pair of vertices there is at least one simple path by connectedness. There cannot be two different simple paths with the same endpoints: follow them to their first divergence and subsequent reunion to obtain a cycle. Conversely, if every pair has exactly one simple path, the graph is connected and cannot contain a cycle, since two portions of that cycle would give competing paths.
Every tree with at least two vertices has a leaf, meaning a degree-one vertex. Choose a longest simple path. An endpoint cannot have an extra neighbor outside the path, which would extend it, or an extra neighbor farther along the path, which would create a cycle. Both endpoints are therefore leaves. Finiteness matters to the longest-path argument; an infinite doubly infinite chain has no leaves. The one-vertex tree is also a special case: its sole vertex has degree zero.
Count edges by removing leaves
Remove a leaf and its incident edge from a tree with at least two vertices. The remaining graph stays connected because a simple path between remaining vertices never needs the leaf, and deleting edges cannot create cycles. Induction from the one-vertex tree therefore gives one fewer edge than vertices. A forest is a graph with no cycles, so applying the formula to each of its components gives the more general edge count in the equation below.
The count becomes a characterization when combined with another property. A connected graph with edges is a tree: repeatedly delete cycle edges while maintaining connectedness, producing a spanning tree with edges, so there were no surplus edges to delete. Edge count alone is insufficient. A triangle together with an isolated vertex has four vertices and three edges but is disconnected and contains a cycle. Always track which extra hypothesis converts a numerical identity into a structural certificate.
Extract a backbone, then understand redundancy
Every finite connected graph contains a spanning tree, a subgraph that retains all vertices and is a tree. One construction repeatedly removes an edge on a cycle; the remaining part of that cycle still connects its endpoints, so connectivity survives. Another keeps only predecessor edges from a search. These arguments establish existence without assigning edge weights. A minimum spanning tree requires an additional optimization question about total weight and should not be confused with an arbitrary search tree.
Adding a new edge between two vertices of a tree closes exactly one cycle: the new edge plus the unique old path between its endpoints. Removing any edge of that cycle returns a spanning tree. By contrast, deleting any original tree edge separates the vertices into two components, since an alternate connection would have formed a cycle. This exchange picture is the basis of many efficient algorithms and also explains the resilience tradeoff: extra edges buy alternate routes, while a bare tree makes every edge a bridge.
Work it through
Identify the one redundant edge
A graph on has edges . Build a spanning tree and describe what happens when the deleted edge is restored.
The five listed edges form a five-cycle. Delete ea. The remaining graph is the path a–b–c–d–e, which still includes all vertices and has no cycle.
The resulting spanning tree has five vertices and four edges, matching the tree formula. Its unique a-to-e path uses all four retained edges.
Restore ea. It closes the unique cycle consisting of that four-edge path and the restored edge. Deleting any one edge of this cycle leaves a spanning path; deleting a tree edge before restoring ea instead disconnects the backbone.
Any four cycle edges form a spanning tree; the fifth edge provides one independent cycle.
The living notebook
Explore the model
Interactive lab · modular
A cycle and its path backbone
Pause and Reset, then set m = 5 and a = 1. Step four times and record the edges 0→1→2→3→4. Ignoring orientation, these four edges form a spanning path on the five residues. Predict the fifth Step closes a single cycle, then check. Reset and set both m = 6 and a = 2 to see why a shorter orbit does not span all six vertices.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA spanning tree must include every vertex; completing a cycle adds redundancy rather than a new vertex.
Pause & reason
Check your understanding
Your turn
Try it yourself
A forest has nine vertices and three components. How many edges does it have? After adding an edge between two different components, determine its new component and edge counts and whether a cycle appears.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Sum the tree edge counts over the components. For the added edge, ask whether an old path between its endpoints existed.
Compare with the solution
The forest has nine minus three, hence six edges. An edge between two different components merges them, giving two components and seven edges. It cannot create a cycle because the two endpoints had no preexisting connecting path. The result is another forest, and its seven edges agree with nine minus two. If the edge had instead joined two vertices already in one component, the unique existing path would have closed a cycle.
Keep the idea
Take it with you
- A tree has a unique simple path between every pair of vertices.
- A forest satisfies edges = vertices − components.
- A spanning tree is minimally connected; one added edge creates exactly one cycle.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.