# 树（图论）

树是一种连通且无环的图：任意两个顶点之间都存在一条路径，且不存在一个边序列在不重复边的情况下回到起点。连通性与无环性的这种结合，使树成为维系一组顶点相互关联的最小结构，也使树在组合数学、计算机科学与网络设计中占据核心地位。

| 关键事实 | 详情 |
|---|---|
| 定义 | 树是连通、无环（不含圈）的图<sup>[1](https://openstax.org/books/contemporary-mathematics/pages/12-10-trees)</sup> |
| 边数 | 含 \( n \) 个顶点的树恰有 \( n-1 \) 条边；反之，含 \( n \) 个顶点和 \( n-1 \) 条边的连通图是树<sup>[2](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Elementary_Foundations%3A_An_Introduction_to_Topics_in_Discrete_Mathematics_%28Sylvestre%29/16%3A_Trees_and_searches/16.03%3A_Identifying_Trees)</sup> |
| 唯一路径 | 树中任意两个不同顶点之间恰有一条简单路径<sup>[3](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Applied_Discrete_Structures_%28Doerr_and_Levasseur%29/10%3A_Trees/10.01%3A_What_is_a_Tree)</sup> |
| 脆弱性 | 删去任意一条边都会使树不连通，而添加任意一条边都会产生圈<sup>[4](https://www.cs.toronto.edu/~shaharry/csc236-summer-2025/lectures/l2-b.html)</sup> |
| 计数 | 含 \( n \) 个顶点的标号树的数量为 \( n^{n-2} \)（凯莱公式）<sup>[5](https://senior-stack.uz/Roadmap/Data/datastructures-and-algorithms/11-graphs/32-prufer-code/professional/)</sup> |
| 生成树 | 一个图的生成树数量等于其拉普拉斯矩阵的任意一个余子式（基尔霍夫矩阵树定理）<sup>[6](https://encyclopediaofmath.org/wiki/Matrix_tree_theorem)</sup> |
| 起源 | 阿瑟·凯莱于1857年写下了他的第一篇关于树的论文<sup>[7](https://www.ams.org/books/spec/108/spec108-endmatter.pdf)</sup> |

## 定义与等价刻画

通常的定义包含两部分。若图中任意两个不同顶点之间都存在路径，则称该图连通；若图中不含圈，则称该图无环。同时满足这两个条件的图就是树<sup>[1](https://openstax.org/books/contemporary-mathematics/pages/12-10-trees)</sup><sup> • </sup><sup>[4](https://www.cs.toronto.edu/~shaharry/csc236-summer-2025/lectures/l2-b.html)</sup>。

对于含 \( n \) 个顶点的有限图 \( G \)，以下若干命题彼此等价，因此其中任何一条都可以作为定义<sup>[2](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Elementary_Foundations%3A_An_Introduction_to_Topics_in_Discrete_Mathematics_%28Sylvestre%29/16%3A_Trees_and_searches/16.03%3A_Identifying_Trees)</sup><sup> • </sup><sup>[3](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Applied_Discrete_Structures_%28Doerr_and_Levasseur%29/10%3A_Trees/10.01%3A_What_is_a_Tree)</sup>：

1. \( G \) 连通且无环。
2. \( G \) 连通且恰有 \( n-1 \) 条边。
3. \( G \) 无环且恰有 \( n-1 \) 条边。
4. 任意两个不同顶点之间恰有一条简单路径。
5. \( G \) 连通，且每条边都是桥，即删去该边会使图不连通。
6. \( G \) 无环，且添加任意一条新边都会产生圈。

最后两条刻画了一种极小连通、极大无环的结构：边再多一条就会出现圈，边再少一条图就会散架，树恰好处于这个平衡点上<sup>[4](https://www.cs.toronto.edu/~shaharry/csc236-summer-2025/lectures/l2-b.html)</sup>。边数 \( n-1 \) 往往是最便捷的实用判据；例如，一个含六个顶点、五条边的连通图，仅凭边数即可确认它是树<sup>[1](https://openstax.org/books/contemporary-mathematics/pages/12-10-trees)</sup>。

## 森林与有根树

不含圈但可以不连通的图称为森林；森林的每个连通分量本身都是一棵树<sup>[3](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Applied_Discrete_Structures_%28Doerr_and_Levasseur%29/10%3A_Trees/10.01%3A_What_is_a_Tree)</sup>。因此，从一棵树中删去一条边，得到的森林恰好包含两棵树<sup>[3](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Applied_Discrete_Structures_%28Doerr_and_Levasseur%29/10%3A_Trees/10.01%3A_What_is_a_Tree)</sup>。

**有根树。** 计算机科学中的大多数树都是有根树，即指定其中一个顶点作为根<sup>[8](https://www.csd.uwo.ca/~abrandt5/teaching/DiscreteStructures/Chapter7/graphs.html)</sup>。选定根之后，其他每个顶点都有了父节点，即距离根更近一步的邻接顶点，并由此引入家族式的术语：子节点、后代和层级，其中顶点的层级是它到根的距离<sup>[8](https://www.csd.uwo.ca/~abrandt5/teaching/DiscreteStructures/Chapter7/graphs.html)</sup>。由于树中的路径是唯一的，这种父节点指派是明确的，每个非根顶点都确定一棵由它自身及其所有后代构成的子树<sup>[8](https://www.csd.uwo.ca/~abrandt5/teaching/DiscreteStructures/Chapter7/graphs.html)</sup>。

## 树的计数

**凯莱公式。** 含 \( n \) 个顶点的标号树（即顶点带有不同标号的树）的数量，对所有 \( n \geq 1 \) 都是 \( n^{n-2} \)<sup>[5](https://senior-stack.uz/Roadmap/Data/datastructures-and-algorithms/11-graphs/32-prufer-code/professional/)</sup>。小规模的情形显示了这一规律：3个标号顶点上有1棵树，4个上有16棵，5个上有125棵<sup>[9](https://appliedcombinatorics.org/book/s_graphs_counting-trees.html)</sup>。同一个数 \( n^{n-2} \) 也计数完全图 \( K_n \) 的生成树<sup>[6](https://encyclopediaofmath.org/wiki/Matrix_tree_theorem)</sup>。

**普吕弗编码。** 1918年，37岁去世、仅发表过九篇论文的德国数学家海因茨·普吕弗给出了凯莱公式的一个构造性证明<sup>[10](https://mathshistory.st-andrews.ac.uk/Extras/Prufer_publications/)</sup><sup> • </sup><sup>[11](https://learngraphtheory.org/articles/trees-in-graph-theory.html)</sup>。他的方法在含 \( n \) 个顶点的标号树与取自 \( \{1, \dots, n\} \) 的长度为 \( n-2 \) 的序列之间建立双射：每一步删去剩余的最小叶节点，并写下它的邻接顶点，由此得到普吕弗序列<sup>[11](https://learngraphtheory.org/articles/trees-in-graph-theory.html)</sup>。由于这样的序列共有 \( n^{n-2} \) 个，树也就有 \( n^{n-2} \) 棵。这种编码还把度数问题转化为计数问题：标号为 \( i \) 的顶点在序列中恰好出现 \( d_i - 1 \) 次，其中 \( d_i \) 是它的度数<sup>[5](https://senior-stack.uz/Roadmap/Data/datastructures-and-algorithms/11-graphs/32-prufer-code/professional/)</sup>。

**基尔霍夫定理。** 若要计数任意图的生成树，归功于古斯塔夫·基尔霍夫的矩阵树定理指出：若 \( L \) 是无自环无向图的拉普拉斯矩阵，\( L^* \) 是删去任意一行和一列后得到的矩阵，则生成树的数量 \( \tau(G) \) 等于 \( \det(L^*) \)，即 \( L \) 的任意一个余子式<sup>[6](https://encyclopediaofmath.org/wiki/Matrix_tree_theorem)</sup>。该定理将生成树计数与电网络分析联系起来，在后者中它把有效电导的计算归结为生成树计数<sup>[12](https://www.mathnet.ru/eng/rm10269)</sup>。

## 生成树与最小生成树

连通图的生成树是这样一个子图：它包含全部顶点，只使用原图的边，且本身是一棵树<sup>[1](https://openstax.org/books/contemporary-mathematics/pages/12-10-trees)</sup>。含 \( n \) 个顶点的连通图总有恰含 \( n-1 \) 条边的生成树，而一棵树恰好只有一个生成树，即它自身<sup>[13](https://mathworld.wolfram.com/SpanningTree.html)</sup>。

当边带有权值时，最小生成树（MST）是总边权最小的生成树。两种经典的贪心算法可以解决这一问题。克鲁斯卡尔算法由小约瑟夫·B·克鲁斯卡尔于1956年发表，它把所有边按权值排序，依次加入不产生圈的最便宜的边，并用并查集结构检测圈；其运行时间为 \( O(E \log V) \)，主要开销在排序上<sup>[14](https://www.cs.yale.edu/homes/lans/readings/routing/kruskal-1956.pdf)</sup><sup> • </sup><sup>[15](https://csiflabs.cs.ucdavis.edu/~tyfeng/ecs34/C%2B%2B/graphs5.html)</sup>。普里姆算法则从任意起始顶点出发生长一棵树，反复加入连接该树与新顶点的最便宜的边；使用二叉堆时运行时间为 \( O(E \log V) \)，使用斐波那契堆时为 \( O(E + V \log V) \)<sup>[16](https://ocw.mit.edu/courses/6-046j-design-and-analysis-of-algorithms-spring-2012/bb54568c86c60d86b25e9c1111470384_MIT6_046JS12_lec04.pdf)</sup>。克鲁斯卡尔方法适合稀疏图，而普里姆算法的数组实现为 \( O(V^2) \)，在稠密图中往往更受青睐<sup>[15](https://csiflabs.cs.ucdavis.edu/~tyfeng/ecs34/C%2B%2B/graphs5.html)</sup>。

## 历史

阿瑟·凯莱（Arthur Cayley，1821–1895）是英国数学家，以矩阵和抽象群方面的基础性工作著称，他于1857年写下了第一篇关于树的论文《论所谓树的解析形式理论》<sup>[7](https://www.ams.org/books/spec/108/spec108-endmatter.pdf)</sup><sup> • </sup><sup>[17](https://www.tandfonline.com/doi/abs/10.1080/14786445708642275)</sup>。他用这个词来描述迭代偏微分时出现的分支现象，并未给出明确定义<sup>[18](https://blogs.ams.org/matheducation/2015/01/20/using-primary-source-projects-to-teach-mathematics/)</sup>。1874年，他将树计数方法应用于枚举饱和烃（烷烃）\( \mathrm{C}_k\mathrm{H}_{2k+2} \) 的结构异构体，把一个化学问题转化为计数具有指定性质的树的问题<sup>[19](https://www.shahucollegelatur.org.in/Department/Studymaterial/sci/it/BCS/FY/book.pdf)</sup>。他1889年关于标号树枚举的结果，就是如今所称的凯莱公式<sup>[7](https://www.ams.org/books/spec/108/spec108-endmatter.pdf)</sup>。基尔霍夫在19世纪40年代关于电网络的工作则以一种互补的方式引入了生成树，其途径是必须从网络图中删去以留下一棵树的弦，尽管基尔霍夫本人起初并不是为了计数它们<sup>[20](https://hrcak.srce.hr/172895)</sup>。

## 应用

树出现在数学及其应用的各个领域。在化学中，烷烃等无环化合物的分子图是树，计数不同的树就是计数不同的异构体<sup>[19](https://www.shahucollegelatur.org.in/Department/Studymaterial/sci/it/BCS/FY/book.pdf)</sup>。在演化生物学中，系统发生树表示物种之间的关系；当发生杂交或水平基因转移等网状事件时，一棵树可能不够用，系统发生网络便推广了树模型<sup>[21](https://pubmed.ncbi.nlm.nih.gov/35503141/)</sup>。在网络设计中，最小生成树是连接一组站点的最便宜方式，但由于树的每条边都是桥，一根电缆被切断就会使其后的所有部分断开；实际设计常增加链路以构成环，从而在任意一处故障下仍能存活<sup>[22](https://learngraphtheory.org/articles/network-design.html)</sup>。在计算机科学中，有根树是二叉树、四叉树和八叉树等数据结构的基础<sup>[8](https://www.csd.uwo.ca/~abrandt5/teaching/DiscreteStructures/Chapter7/graphs.html)</sup>。

## References

1. [12.10 Trees, Contemporary Mathematics, OpenStax](https://openstax.org/books/contemporary-mathematics/pages/12-10-trees)
2. [16.3: Identifying Trees, Elementary Foundations (Sylvestre), Mathematics LibreTexts](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Elementary_Foundations%3A_An_Introduction_to_Topics_in_Discrete_Mathematics_%28Sylvestre%29/16%3A_Trees_and_searches/16.03%3A_Identifying_Trees)
3. [10.1: What is a Tree?, Applied Discrete Structures (Doerr and Levasseur), Mathematics LibreTexts](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Applied_Discrete_Structures_%28Doerr_and_Levasseur%29/10%3A_Trees/10.01%3A_What_is_a_Tree)
4. [Lecture 02: Graphs, CSC236, University of Toronto](https://www.cs.toronto.edu/~shaharry/csc236-summer-2025/lectures/l2-b.html)
5. [Prüfer Code: Mathematical Foundations and Proofs, Senior Stack](https://senior-stack.uz/Roadmap/Data/datastructures-and-algorithms/11-graphs/32-prufer-code/professional/)
6. [Matrix tree theorem, Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Matrix_tree_theorem)
7. [Graph Theory Timeline, AMS/MAA Spectrum](https://www.ams.org/books/spec/108/spec108-endmatter.pdf)
8. [7.1. Graphs, Discrete Structures for Computing, University of Western Ontario](https://www.csd.uwo.ca/~abrandt5/teaching/DiscreteStructures/Chapter7/graphs.html)
9. [Section 5.6 Counting Labeled Trees, Applied Combinatorics](https://appliedcombinatorics.org/book/s_graphs_counting-trees.html)
10. [Heinz Prüfer's publications, MacTutor History of Mathematics](https://mathshistory.st-andrews.ac.uk/Extras/Prufer_publications/)
11. [Trees in Graph Theory, Learn Graph Theory](https://learngraphtheory.org/articles/trees-in-graph-theory.html)
12. [Modern theory of electrical networks: from the matrix-tree theorem to the theory of cluster varieties, Russian Math. Surveys](https://www.mathnet.ru/eng/rm10269)
13. [Spanning Tree, Wolfram MathWorld](https://mathworld.wolfram.com/SpanningTree.html)
14. [J. B. Kruskal (1956), On the Shortest Spanning Subtree of a Graph and the Traveling Salesman Problem](https://www.cs.yale.edu/homes/lans/readings/routing/kruskal-1956.pdf)
15. [Minimum Spanning Trees (MST), ECS 34, UC Davis](https://csiflabs.cs.ucdavis.edu/~tyfeng/ecs34/C%2B%2B/graphs5.html)
16. [6.046J Lecture 4: Minimum spanning trees II, MIT OpenCourseWare](https://ocw.mit.edu/courses/6-046j-design-and-analysis-of-algorithms-spring-2012/bb54568c86c60d86b25e9c1111470384_MIT6_046JS12_lec04.pdf)
17. [A. Cayley (1857), On the theory of the analytical forms called trees, Philosophical Magazine](https://www.tandfonline.com/doi/abs/10.1080/14786445708642275)
18. [Using Primary Source Projects to Teach Mathematics, AMS Blogs](https://blogs.ams.org/matheducation/2015/01/20/using-primary-source-projects-to-teach-mathematics/)
19. [Graph Theory with Applications to Engineering and Computer Science (excerpt on Cayley and alkane isomers)](https://www.shahucollegelatur.org.in/Department/Studymaterial/sci/it/BCS/FY/book.pdf)
20. [What Kirchhoff Actually did Concerning Spanning Trees in Electrical Networks, Hrčak](https://hrcak.srce.hr/172895)
21. [Classes of explicit phylogenetic networks and their biological and mathematical significance, PubMed](https://pubmed.ncbi.nlm.nih.gov/35503141/)
22. [Telecom Network Design Optimization, Learn Graph Theory](https://learngraphtheory.org/articles/network-design.html)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Graph theory › Graph theory overview and basic objects

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/tree-graph-theory

English original: https://www.edgepedia.org/tree-graph-theory
