Combinatorics and discrete mathematics
Trees
Connected graphs with no cycles, the simplest and most structured kind of network.
IntuitionNetworks with no shortcuts
A family tree, a company's org chart, a computer file system, and a decision tree in a game all share the same shape: every two points are connected by exactly one path, with no loops to get lost in. Add one more link between two branches of a family tree and you create a cycle — a shortcut that breaks this "exactly one path" property. A tree is the mathematical name for a connected network with the fewest possible edges: remove any single edge and it falls apart into two pieces; add any single edge and it creates a cycle.
UndergraduateFormal definitions
Definition: Tree
A tree is a graph that is both connected (there is a path between every pair of vertices) and acyclic (it contains no cycle). A vertex of degree in a tree is called a leaf. A graph in which every connected component is a tree (so it need not itself be connected) is called a forest.
This is the tree's defining balance: with vertices, a tree has exactly edges — just enough to keep everything connected, with nothing left over to create a cycle. Summing degrees over all vertices and using the handshake lemma () gives a companion identity that will be useful when counting leaves and internal vertices.
| Condition | Edge count | Extra property |
|---|---|---|
| Connected and acyclic | exactly | unique path between every pair of vertices |
| Connected with edges | removing any edge disconnects it | |
| Acyclic with edges | adding any edge creates exactly one cycle | |
| Disconnected graph with edges (not a tree) | has a cycle somewhere despite the edge count matching |
UndergraduateKey theorems
For a graph with vertices, the following are equivalent: (i) is connected and acyclic; (ii) is connected with edges; (iii) is acyclic with edges.
Why is it true?
Removing any edge from a tree disconnects it, and adding any edge creates a cycle — a tree has exactly the number of edges needed to connect everything, with no redundancy and no shortage. These three conditions each pin down that "just enough" structure from a different angle.
Proof
We show (i) connected and acyclic (ii) connected with edges (iii) acyclic with edges (i), which chains all three together.
**(i)(ii)**, by induction on . The base case is immediate: a single vertex has edges. For the inductive step, take a connected acyclic graph on vertices. Since is finite and acyclic, it must contain a leaf (a vertex of degree ): otherwise every vertex would have degree , and following edges out of any starting vertex without immediately backtracking would eventually revisit a vertex, producing a cycle. Deleting and its one incident edge leaves a graph on vertices that is still connected ( had no other vertices depending on it to stay connected) and still acyclic (a subgraph of an acyclic graph is acyclic). By the inductive hypothesis, has edges, so has edges.
**(ii)(iii)**. Suppose is connected with edges. If had a cycle, deleting one edge of that cycle would keep the graph connected (the two endpoints of the deleted edge are still joined by the rest of the cycle), giving a connected graph on vertices with only edges. But any connected graph on vertices needs at least edges (each new vertex beyond the first needs at least one new edge to reach it), so edges cannot connect vertices — a contradiction. So has no cycle, i.e. it is acyclic.
**(iii)(i)**. Suppose is acyclic with edges, and let it have connected components. Each component is itself connected and acyclic, so by the already-proven direction (i)(ii) applied to each component separately, a component with vertices has edges. Summing over all components, the total edge count is . Since the total is given as , we get , so : is connected.
The number of distinct labeled trees on the vertex set (for ) is .
Why is it true?
It answers a purely combinatorial question — how many different ways can distinguishable points be wired into a tree-shaped network — with a strikingly simple closed formula, and the encoding trick used to prove it (Prüfer sequences) turns "count the trees" into "count the sequences," a much easier problem.
Proof
Fix the vertex set and, for , define the Prüfer sequence of a labeled tree : repeatedly find the leaf with the smallest label, write down the label of its unique neighbor, and delete that leaf; stop once vertices remain. This records labels (one per deletion, since we start with vertices and stop at ), so every labeled tree produces a sequence in .
There are exactly such sequences, since each of the positions is independently any of the labels. It remains to show this encoding is a bijection, so that labeled trees are in exact one-to-one correspondence with these sequences.
The key fact is that in the Prüfer sequence, label appears exactly times: every time one of 's neighbors is deleted as a leaf, is written down once, and itself is only ever deleted (contributing no writes) once all but one of its incident edges are gone. In particular, the labels that never appear in the sequence are exactly the original leaves. This lets us decode: given a sequence , repeatedly take the smallest label not currently used as a remaining sequence entry or already attached, join it by an edge to the first remaining sequence entry, remove that label from further consideration and remove that entry from the sequence; after all entries are consumed, join the labels left over by a final edge.
This decoding procedure exactly reverses the encoding step by step — at each stage it identifies the same smallest-label leaf and the same neighbor that the encoder would have recorded, by induction on the number of vertices remaining. So encoding and decoding are mutually inverse, giving a bijection between labeled trees on vertices and sequences in . Since there are such sequences, there are exactly labeled trees on vertices.
UndergraduateReal-World Applications and Worked Examples
Trees are the backbone of hierarchical and routing structures everywhere: file systems, phylogenetic trees in biology, decision trees in machine learning, and binary search trees and Huffman codes in computer science. One of the most direct engineering uses is network design: when a company must connect a set of offices, sensors, or computers with cables or wireless links at minimum cost, the cheapest connected layout is always a spanning tree — connecting them with a cycle would waste money on a redundant link. Kruskal's algorithm finds this cheapest tree by a simple greedy rule: sort all possible links by cost, and add each one in turn unless it would close a cycle.
Example: Minimum-cost cabling via Kruskal's algorithm
Five relay towers need to be connected by fiber cable at minimum total length. The possible links and their lengths (km) are: , , , , , , , . Find the minimum total cable length needed to connect all five towers.
Solution
Sort the candidate links by increasing length: , , , , , , , . Kruskal's algorithm scans this list once, adding a link unless both of its endpoints are already connected by previously chosen links (which would create a cycle).
Add (towers were separate, now joined). Add (joins tower to the group, now ). Add (towers were separate, now joined into ).
Skip : both and are already in the group , so adding this link would close a cycle. Add : this joins the two remaining groups and into one group of all towers.
At this point links have been added, matching edges for a tree on vertices, so the algorithm stops (every later link would only create a cycle). The total minimum cable length is km.
Example: Counting possible backbone topologies
A telecom company plans to connect distinguishable relay stations with a loop-free (tree-shaped) backbone network, with no constraint yet on which pairs get linked. How many structurally different labeled tree topologies are possible?
Solution
By Cayley's formula, the number of labeled trees on vertices is . Here , so the count is .
Computing, . So there are structurally different tree topologies connecting the stations.
For a network planner, this huge design space is exactly why nobody enumerates all possibilities by hand: instead, an optimization procedure like Kruskal's algorithm (Theorem 1's edge-counting property guarantees any candidate has exactly links) picks out the one cheapest tree directly from the link costs, without ever listing the others.
A tree has vertices. How many edges does it have?
By Cayley's formula, how many distinct labeled trees are there on vertices?
A cable company must connect offices with the cheapest possible network (no redundant links). Using Kruskal's algorithm on the sorted link costs, how many links will the final network have?
A graph has vertices and edges, but is split into separate connected pieces (one of which contains a cycle). Which characterization from Theorem 1 does this graph fail, even though its edge count matches ?
References
- Reinhard Diestel (2017). Graph Theory
- David R. Karger, Philip N. Klein, Robert E. Tarjan (1995). A randomized linear-time algorithm to find minimum spanning trees · DOI:10.1145/201019.201022
- Aaron Schild (2017). An almost-linear time algorithm for uniform random spanning tree generation · arXiv:1711.06455 [preprint, not peer-reviewed]