# 支配者（图论）

在图论中，流图里顶点 v 的**支配者**是指这样的顶点 w：从指定根（入口）顶点 r 到 v 的每条路径都经过 w。该概念适用于有向图，其中每个顶点都可从某个特定根到达，它刻画了在到达 v 的途中遍历无法避开的那些顶点。<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 若从根 r 到 v 的每条路径都包含 w，则顶点 w 支配 v；根支配所有可达顶点，每个顶点支配自身<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup> |
| 首次出现 | R. T. Prosser 在 1959 年一篇关于流程图分析的论文中引入了支配概念<sup>[2](https://www.researchgate.net/publication/2569680_A_Simple_Fast_Dominance_Algorithm)</sup> |
| 支配者树 | 除根以外的每个顶点都有唯一的直接支配者，即最近的支配者；这些直接支配者就是支配者树中对应节点的父节点<sup>[3](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.dominance.immediate_dominators.html)</sup> |
| 经典算法 | Lengauer 与 Tarjan 于 1979 年发表在《ACM 程序设计语言与系统汇刊》1(1):121–141 上的算法，包含两个版本，即使在中等规模的图上也比早期的迭代位向量方法快得多<sup>[4](https://bibbase.org/network/publication/lengauer-tarjan-afastalgorithmforfindingdominatorsinaflowgraph-1979)</sup><sup> • </sup><sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup> |
| 简单替代方案 | Cooper、Harvey 和 Kennedy 的迭代算法运行时间为 O(N²)，在实际程序上测得运行速度为 Lengauer-Tarjan 的 2.5 倍<sup>[5](https://hipersoft.cs.rice.edu/grads/publications/dom14.pdf)</sup> |
| 对偶概念 | v 的后支配者是指从 v 到出口节点的每条路径都经过的顶点；后支配者恰好就是将所有边方向反转后图中的支配者<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup><sup> • </sup><sup>[6](https://www.cs.cornell.edu/courses/cs4120/2019sp/lectures/25reachdef/lec25-sp19.pdf?1557261396=)</sup> |
| 应用 | 程序优化、电路测试和理论生物学<sup>[7](https://www.cs.princeton.edu/research/techreps/432)</sup> |

## 定义与基本性质

流图 G = (V, A, r) 是一个具有 n 个顶点和 m 条弧的有向图，其中每个顶点都可从特定根顶点 r 到达。若从 r 到 v 的每条路径都包含 w，则顶点 w 支配顶点 v。支配者计算的目标是为每个顶点 v 找出支配 v 的所有顶点构成的集合 Dom(v)。<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup>

支配关系是一个偏序：它具有自反性，因为每个顶点支配自身；它具有传递性，因为位于通往 v 的每条路径上的顶点，也位于通往 v 所支配的任何顶点的每条路径上。除根以外的每个顶点 v 都有唯一的**直接支配者**：它是 v 的严格支配者，且被 v 的所有其他严格支配者所支配。由于除根以外的每个顶点恰好有一个直接支配者，支配关系可以表示为一棵树，即支配者树，其中直接支配者是其对应节点的父节点。<sup>[3](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.dominance.immediate_dominators.html)</sup><sup> • </sup><sup>[8](https://courses.cs.washington.edu/courses/cse401/22sp/lectures/P-ssa.pdf)</sup> 于是，关于一个顶点是否支配另一个顶点的查询就归结为这棵树中的祖先测试。

对偶概念是**后支配**：若从 B 到出口节点的所有路径都经过 A，则节点 A 后支配节点 B。这恰好发生在 A 在转置控制流图中支配 B 的时候，转置控制流图将所有边方向反转，并交换起始节点和出口节点。<sup>[6](https://www.cs.cornell.edu/courses/cs4120/2019sp/lectures/25reachdef/lec25-sp19.pdf?1557261396=)</sup>

## 起源与历史

支配概念由 R. T. Prosser 在 1959 年一篇关于流程图分析的论文中引入。<sup>[2](https://www.researchgate.net/publication/2569680_A_Simple_Fast_Dominance_Algorithm)</sup> 1972 年，Frances Allen 和 John Cocke 证明支配关系可以从一组数据流方程迭代计算出来，给出了该问题的第一个系统方法。<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup>

数据流表述是直接的。定义 out(n) 为支配 n 的节点集合；由于支配是自反的，out(n) 包含 n 本身。任何其他支配 n 的节点也必须支配 n 的所有前驱，否则就会存在一条到达 n 却避开它的路径。由此得到方程

\[ out(n) = \{n\} \cup \bigcap_{n' \prec n} out(n') \]

适用于除起始节点以外的节点，且 out(START) = {START}。作为前向分析求解，初始时每个集合包含所有节点，传递函数是单调的，并对交汇算子（交集）满足分配律。<sup>[6](https://www.cs.cornell.edu/courses/cs4120/2019sp/lectures/25reachdef/lec25-sp19.pdf?1557261396=)</sup>

## 算法

**Lengauer-Tarjan。** 最著名的快速算法由 Thomas Lengauer 和 Robert Endre Tarjan 提出，于 1979 年发表在《ACM 程序设计语言与系统汇刊》上，题为“一种在流图中寻找支配者的快速算法”（第 1 卷，第 1 期，第 121–141 页）。<sup>[4](https://bibbase.org/network/publication/lengauer-tarjan-afastalgorithmforfindingdominatorsinaflowgraph-1979)</sup> 该文提出了两个版本，最初的实验比较发现，即使在中等规模的图上，两者都比迭代位向量算法快得多。<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup> 该算法基于图的深度优先搜索，先计算半支配者，再计算直接支配者。<sup>[9](https://www.researchgate.net/publication/220639563_Finding_Dominators_in_Practice)</sup> 更早的时候，Tarjan 描述了一种针对任意有向图的算法，使用深度优先搜索、不相交集合合并和优先队列，达到 O(V log V + E) 的时间界，改进了此前已知任意有向图算法的 O(V(V + E)) 界；当 E ≥ V log V 时，其运行时间为 O(E)。<sup>[10](https://epubs.siam.org/doi/10.1137/0203006)</sup>

**Cooper-Harvey-Kennedy 迭代算法。** 莱斯大学的 Keith D. Cooper、Timothy J. Harvey 和 Ken Kennedy 将支配问题重新作为全局数据流问题来处理。利用对支配信息结构的洞察，他们设计了一种基于树的支配集表示，得到 O(N²) 算法，在他们的测量中，该算法在实际程序上的运行速度为经典的 Lengauer-Tarjan 算法的 2.5 倍。在 30,000 个节点的控制流图上——规模接近 SPEC 基准中最大控制流图的 40 倍——两种方法耗时基本相同。他们认为，其简洁性使其易于实现、理解和教学。<sup>[5](https://hipersoft.cs.rice.edu/grads/publications/dom14.pdf)</sup> 同一篇论文还从 Ferrante 及其同事早期关于控制依赖的工作中重新推导出计算支配边界的方法。<sup>[5](https://hipersoft.cs.rice.edu/grads/publications/dom14.pdf)</sup>

**后续比较。** 受 Cooper 等人结果的启发，Loukas Georgiadis、Robert E. Tarjan 和 Renato F. Werneck 进行了一项实验研究，将迭代算法及其变体与两个版本的 Lengauer-Tarjan 的精心实现以及一种新的混合算法进行比较。他们的研究发表于 2006 年《图算法与应用杂志》（第 10 卷，第 1 期，第 69–94 页），发现所有算法的性能大致相当，其中基本的 Lengauer-Tarjan 算法和混合算法在速度上最为稳定，并且随着图变得更大或更复杂，这一优势还会扩大。<sup>[11](https://collaborate.princeton.edu/en/publications/finding-dominators-in-practice/)</sup> Georgiadis 2005 年的普林斯顿博士论文研究了这些算法以及一种新的实用算法和线性时间方法。<sup>[7](https://www.cs.princeton.edu/research/techreps/432)</sup>

**动态维护。** 当程序被变换时，其控制流图会发生变化，因此支配者树必须更新而不是重新计算。动态支配者的研究工作产生了一种简单的增量方法，用于在 k 次边插入过程中更新具有 n 个顶点的流图的支配者树，运行时间为 O(m min{n, k} + kn)，其中 m 表示所有插入完成后的边数。<sup>[12](https://arxiv.org/abs/1604.02711)</sup> 相关工作提供了第一个在边删除下维护支配者树的非平凡算法。<sup>[13](https://arxiv.org/abs/1704.08235)</sup>

## 在编译器中的应用

编译器在程序分析和优化过程中广泛使用支配信息，用于自然循环检测（从而实现一系列循环优化）、结构分析、指令调度，以及依赖图和静态单赋值（SSA）形式的计算等目标。<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup>

**SSA 构造。** 将代码转换为 SSA 形式（每个变量恰好赋值一次）在两个层面上依赖支配关系。首先，变量的定义必须支配其使用，因此支配者树记录了值在何处可用。其次，φ 函数合并来自不同前驱的值，被插入到由支配边界确定的汇合点；随后的重命名遍历沿着支配者树进行。<sup>[6](https://www.cs.cornell.edu/courses/cs4120/2019sp/lectures/25reachdef/lec25-sp19.pdf?1557261396=)</sup><sup> • </sup><sup>[8](https://courses.cs.washington.edu/courses/cse401/22sp/lectures/P-ssa.pdf)</sup>

**在 LLVM 中的实现。** LLVM 编译器基础设施提供了一个 DominatorTree 类，可在函数的控制流图上提供快速的支配查询，由通用模板框架计算，该框架还支持任意图类型上的后支配者树。<sup>[14](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/Dominators.h)</sup><sup> • </sup><sup>[15](https://www.llvm.org/doxygen/GenericDomTree_8h.html)</sup> 由于优化遍会修改控制流图，LLVM 提供了增量更新操作：insertEdge 和 deleteEdge 将单条边的变化告知树，applyUpdates 对一系列插入和删除执行批量更新，重新排序更新并移除相互抵消的冗余更新。<sup>[16](https://www.llvm.org/docs/doxygen/classllvm_1_1DominatorTree.html)</sup> DominatorTreeUpdater 在急切或惰性策略下管理这些更新，惰性策略将工作推迟到查询需要时。<sup>[17](https://llvm.org/docs/doxygen/DomTreeUpdater_8h_source.html)</sup>

**其他领域。** 除编译器外，支配者还用于识别 VLSI 电路中成对的等效线路故障，该概念在理论生物学中也有应用。<sup>[1](https://liberty.princeton.edu/Publications/esa_dom.pdf)</sup><sup> • </sup><sup>[7](https://www.cs.princeton.edu/research/techreps/432)</sup> 通用图库直接提供该计算：NetworkX 的 immediate_dominators 函数返回从起始节点可达的所有节点的直接支配者，后支配者可以通过在反向图上调用该函数获得。<sup>[3](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.dominance.immediate_dominators.html)</sup>

## 验证与认证

快速支配者算法很复杂，验证计算出的支配者树是否正确本身就不平凡。一种方法是对原程序进行增广，使其不仅产生输出，还产生正确性证书，这样一个非常简单、其正确性易于证明的程序就能验证输入-输出对满足所需关系。这个支配者认证问题与在流图中寻找独立生成树的问题相关。<sup>[18](https://arxiv.org/abs/1210.8303)</sup> Cooper-Harvey-Kennedy 表述也已被机械化形式化：2021 年《形式证明档案》中的一项工作在 Kildall 风格框架中形式化了快速迭代算法，并证明了其相对于控制流图上支配者规范的正确性和完备性。<sup>[19](https://www.isa-afp.org/entries/Dominance_CHK.html)</sup>

## References

1. [Georgiadis, L., Werneck, R. F., Tarjan, R. E., Triantafyllis, S., and August, D. I. Finding Dominators in Practice.](https://liberty.princeton.edu/Publications/esa_dom.pdf)
2. [Cooper, K. D., Harvey, T. J., and Kennedy, K. A Simple, Fast Dominance Algorithm (ResearchGate copy).](https://www.researchgate.net/publication/2569680_A_Simple_Fast_Dominance_Algorithm)
3. [NetworkX documentation: immediate_dominators.](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.dominance.immediate_dominators.html)
4. [Lengauer, T. and Tarjan, R. E. (1979). A fast algorithm for finding dominators in a flowgraph. ACM TOPLAS 1(1):121–141.](https://bibbase.org/network/publication/lengauer-tarjan-afastalgorithmforfindingdominatorsinaflowgraph-1979)
5. [Cooper, K. D., Harvey, T. J., and Kennedy, K. A Simple, Fast Dominance Algorithm (Rice University).](https://hipersoft.cs.rice.edu/grads/publications/dom14.pdf)
6. [Cornell CS 4120/5120, Lecture 25: Dominators and SSA.](https://www.cs.cornell.edu/courses/cs4120/2019sp/lectures/25reachdef/lec25-sp19.pdf?1557261396=)
7. [Georgiadis, L. Linear-Time Algorithms for Dominators and Related Problems, Princeton TR-737-05.](https://www.cs.princeton.edu/research/techreps/432)
8. [University of Washington CSE 401, lecture on SSA.](https://courses.cs.washington.edu/courses/cse401/22sp/lectures/P-ssa.pdf)
9. [Georgiadis, L., Tarjan, R. E., and Werneck, R. F. Finding Dominators in Practice (ResearchGate).](https://www.researchgate.net/publication/220639563_Finding_Dominators_in_Practice)
10. [Tarjan, R. Finding Dominators in Directed Graphs. SIAM Journal on Computing 3(1):62–89, 1974.](https://epubs.siam.org/doi/10.1137/0203006)
11. [Georgiadis, L., Tarjan, R. E., and Werneck, R. F. (2006). Finding dominators in practice. Journal of Graph Algorithms and Applications 10(1):69–94.](https://collaborate.princeton.edu/en/publications/finding-dominators-in-practice/)
12. [An Experimental Study of Dynamic Dominators, arXiv:1604.02711.](https://arxiv.org/abs/1604.02711)
13. [Decremental Data Structures for Connectivity and Dominators in Directed Graphs, arXiv:1704.08235.](https://arxiv.org/abs/1704.08235)
14. [LLVM project, llvm/include/llvm/IR/Dominators.h.](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/Dominators.h)
15. [LLVM Doxygen: GenericDomTree.h File Reference.](https://www.llvm.org/doxygen/GenericDomTree_8h.html)
16. [LLVM Doxygen: DominatorTreeBase Class Reference.](https://www.llvm.org/docs/doxygen/classllvm_1_1DominatorTree.html)
17. [LLVM Doxygen: DomTreeUpdater.h Source File.](https://llvm.org/docs/doxygen/DomTreeUpdater_8h_source.html)
18. [Dominator Tree Certification and Independent Spanning Trees, arXiv:1210.8303.](https://arxiv.org/abs/1210.8303)
19. [Jiang, N. (2021). A data flow analysis algorithm for computing dominators. Archive of Formal Proofs.](https://www.isa-afp.org/entries/Dominance_CHK.html)

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

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Graph theory › Computational graph problems and algorithms

Copyright 2026 Edgepedia

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

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

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