# DSatur

**DSatur**（“饱和度”的缩写，也写作DSATUR）是一种用于图着色问题的贪心启发式算法，由丹尼尔·布雷拉兹（Daniel Brélaz）于1979年提出。算法在每一步为未着色顶点中已着色邻居使用了最多种不同颜色的那个顶点着色，这个量称为饱和度；若出现平局，则按普通度数打破。该算法快速且确定，在许多实例上能产生接近最优的着色，并已被证明在若干图族上是最优的，包括二部图、环图、轮图，以及2024年证明的弦图。<sup>[1](https://dblp.org/rec/journals/cacm/Brelaz79.html)</sup><sup> • </sup><sup>[2](https://github.com/NaughtFound/DSatur/blob/main/README.md)</sup><sup> • </sup><sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S0167637724001214)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 由洛桑联邦理工学院的丹尼尔·布雷拉兹在《为图的顶点着色的新方法》中提出，《ACM通讯》22(4)：251–256，1979年4月<sup>[1](https://dblp.org/rec/journals/cacm/Brelaz79.html)</sup> |
| 选择规则 | 为饱和度最大的未着色顶点着色，饱和度即其已着色邻居中不同颜色的数目；平局时按最大度数打破，仍相同则任意选择<sup>[2](https://github.com/NaughtFound/DSatur/blob/main/README.md)</sup><sup> • </sup><sup>[4](https://optimization-online.org/wp-content/uploads/2015/10/5159.pdf)</sup> |
| 复杂度 | 直接实现为O(n²)；若用红黑树存储未着色顶点，则为O((n + m) log n)<sup>[5](https://www.geeksforgeeks.org/dsa/dsatur-algorithm-for-graph-coloring/)</sup> |
| 精确于 | 二部图（布雷拉兹定理1）、环图、轮图，以及弦图（2024年证明）<sup>[6](https://cse.unl.edu/~choueiry/Documents/brelaz.pdf)</sup><sup> • </sup><sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S0167637724001214)</sup> |
| 精确变体 | 基于DSATUR的分支定界法，经休厄尔（Sewell，1996）和圣塞贡多（San Segundo，2012）改进，是顶点着色问题的精确算法<sup>[7](https://www.sciencedirect.com/science/article/pii/S0305054811002966)</sup> |
| 软件 | 在NetworkX中实现为`strategy_saturation_largest_first`<sup>[8](https://networkx.org/documentation/networkx-2.8.8/reference/algorithms/generated/networkx.algorithms.coloring.strategy_saturation_largest_first.html)</sup> |

## 算法

图着色要求用最少数量的颜色为图的顶点标色，使得没有两个相邻顶点共享同一种颜色；这个最小值就是色数χ(G)，求它是NP难的。<sup>[9](https://arxiv.org/abs/2609.17633)</sup> DSatur是一种构造性启发式算法：它一次为一个顶点着色，总是分配该顶点的已着色邻居未使用的最小编号颜色。<sup>[6](https://cse.unl.edu/~choueiry/Documents/brelaz.pdf)</sup>

DSatur与固定顺序贪心着色的区别在于，下一个着色的顶点是根据当前部分着色动态选择的。未着色顶点v的饱和度是v的已着色邻居中出现的不同颜色的数目；两个颜色相同的邻居只计一次。<sup>[4](https://optimization-online.org/wp-content/uploads/2015/10/5159.pdf)</sup>每次迭代选择饱和度最高的未着色顶点，用编号尽可能小的颜色为其着色，并更新其余未着色顶点的饱和度。原始规则中平局按最大度数打破，仍相同则任意或按字典序解决。<sup>[4](https://optimization-online.org/wp-content/uploads/2015/10/5159.pdf)</sup>

用调度的术语来说，这条规则意味着先安排约束最强的项：一个顶点如果在其邻居中已经看到许多不同颜色，那么它剩余的选择最少，因此尽早处理它可以避免后来的强制冲突。<sup>[10](https://github.com/iamademar/dsatur-vs-cpsat)</sup>

## 复杂度与实现

对于有n个顶点的图，直接实现需要O(n²)时间：n轮，每轮通过O(n)扫描确定下一个着色的顶点。<sup>[5](https://www.geeksforgeeks.org/dsa/dsatur-algorithm-for-graph-coloring/)</sup>这与普通贪心着色的最坏情况复杂度相同，尽管DSatur需要额外的记录来跟踪未着色顶点的饱和度。<sup>[11](https://manuals.plus/m/46fb2e3883d25cef498d7d5dd7dad7251c2f3680828975a5774ebfe6ecd27fd7)</sup>更快的实现将所有未着色顶点及其饱和度和在未着色子图中的度数存储在红黑树中，从而可以在常数时间内选择下一个顶点；对于n个顶点和m条边，运行时间为O((n + m) log n)，除最稠密的图外，这比O(n²)快得多。<sup>[5](https://www.geeksforgeeks.org/dsa/dsatur-algorithm-for-graph-coloring/)</sup>

## DSatur何时最优

布雷拉兹证明了DSatur对二部图是精确的，即它总能在二部图上产生使用χ(G)种颜色的着色；证明表明，连通二部图中饱和度为二的顶点会迫使出现奇环，而奇环不可能存在。因此该算法也可作为二部性的多项式时间O(n²)测试。<sup>[6](https://cse.unl.edu/~choueiry/Documents/brelaz.pdf)</sup>后来的工作确立了它在环图和轮图上的精确性。<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S0167637724001214)</sup>2024年，耶克扎雷（Yekezare）、佐赫雷班迪安（Zohrehbandian）、马加塞迪（Maghasedi）和博诺莫-布拉伯曼（Bonomo-Braberman）证明了DSatur在弦图上最优，弦图是区间图的超类，并在此过程中表明弦图上DSatur着色顺序的逆序是一个完美消除序。<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S0167637724001214)</sup>

在一般图上，该启发式并非最优，其失败情形已有充分刻画。扬切夫斯基（Janczewski）、库巴莱（Kubale）、马努舍夫斯基（Manuszewski）和皮瓦科夫斯基（Piwakowski）研究了DSATUR的最小难着色图，发表于《离散数学》236(1–3)：151–165（2001）。<sup>[12](https://dblp.org/pid/p/KonradPiwakowski)</sup>斯平拉德（Spinrad）和维贾扬（Vijayan）构造了一类对抗性的3可着色图族，有3n − 4个顶点，DSATUR可能使用n种颜色，为某些三元组的每个顶点分配不同的颜色；当n = 5时，这意味着在色数为3的图上使用5种颜色。<sup>[9](https://arxiv.org/abs/2609.17633)</sup>即使在某些3可着色图上，无论怎样打破平局，DSatur总是使用四种颜色。<sup>[11](https://manuals.plus/m/46fb2e3883d25cef498d7d5dd7dad7251c2f3680828975a5774ebfe6ecd27fd7)</sup>

## 精确分支定界变体

该启发式规则也是一类精确算法的骨干。在DSATUR分支定界中，搜索节点是一个部分着色；算法在饱和度最大的未着色顶点上分支，为每个可行的已有颜色创建一个子节点，再加上一个使用新颜色的子节点。DSATUR启发式提供第一个上界，贪心团提供下界，当节点的颜色数达到上界时剪枝。不剪枝时，树在颜色重命名意义下恰好枚举每一种可行着色一次，因此算法是精确的。<sup>[13](https://fabiofurini.github.io/combinatorial-optimization/specialized-algorithms/dsatur-branch-and-bound/)</sup>

分支定界DSATUR后来经休厄尔改进，在2012年的一篇综述中被称为“无疑是已知最好的”精确着色算法，并多年成为事实上的标准。<sup>[7](https://www.sciencedirect.com/science/article/pii/S0305054811002966)</sup>休厄尔的平局打破规则显式评估每个未着色顶点的可用颜色；圣塞贡多的PASS算法（2012）仅对受限的候选顶点集应用类似策略，以低得多的成本实现类似的剪枝效果，并在1500个随机图和DIMACS颜色基准的一个子集上进行了测试。<sup>[7](https://www.sciencedirect.com/science/article/pii/S0305054811002966)</sup>基于DSATUR的精确算法也已被适配到公平着色问题，其中各颜色类的大小最多相差一，并从公平约束推导出新的剪枝规则。<sup>[14](https://arxiv.org/abs/1405.7011)</sup>

## 应用

DSatur用于需要快速以合理少的颜色为大图着色的场合。

**排课。** 大学排课自然映射到图着色：课程是顶点，共享学生或教师的两门课程之间连边，因此着色分配考试或上课时段。<sup>[15](https://www.mecs-press.org/ijisa/ijisa-v15-n3/v15n3-2.html)</sup>2023年孟加拉国军事科学技术学院的一项比较研究测试了五种算法（首次适应、威尔士-鲍威尔、最大度数排序、关联度数排序和DSATUR），发现威尔士-鲍威尔和DSATUR在生成最优时间表方面最为有效。<sup>[15](https://www.mecs-press.org/ijisa/ijisa-v15-n3/v15n3-2.html)</sup>2024年巴西一项以学生为中心的时间表分配研究同样比较了暴力法和DSATUR，发现暴力法最优但计算昂贵，而DSATUR在运行时间上极其高效，但不总能保证最优。<sup>[16](https://sol.sbc.org.br/index.php/ercemapi/article/view/30179)</sup>DSATUR还作为精确求解器的热启动：在一次考试排课比较中，Google OR-Tools CP-SAT从DSATUR的着色热启动。<sup>[10](https://github.com/iamademar/dsatur-vs-cpsat)</sup>

**寄存器分配。** 编译器将寄存器分配建模为对干涉图着色，其中节点是计算值，边连接同时活跃的值；IBM的蔡廷（Chaitin）及其同事在1980年代初为PL/I优化编译器建立了这一表述。<sup>[17](https://www.sciencedirect.com/science/article/pii/0096055181900485)</sup>编译器构造教材将采用最受约束优先启发式的基于饱和度的贪心着色描述为大致等价于DSatur。<sup>[18](https://brinckerhoff.org/clements/2194-csc431/essentials-of-compilation.pdf)</sup>

**软件库。** NetworkX将DSATUR作为其贪心着色例程的`strategy_saturation_largest_first`策略公开，与最大优先、随机顺序、最小最后和连通顺序策略并列为几种内置排序之一。<sup>[8](https://networkx.org/documentation/networkx-2.8.8/reference/algorithms/generated/networkx.algorithms.coloring.strategy_saturation_largest_first.html)</sup><sup> • </sup><sup>[19](https://networkx.org/documentation/networkx-1.10/_modules/networkx/algorithms/coloring/greedy_coloring.html)</sup>

## 在着色启发式中的地位

DSATUR仍然是最快的图着色启发式之一，尽管它产生的着色通常比最先进的方法使用更多颜色，因此现在常被用来为其他算法产生初始解。<sup>[9](https://arxiv.org/abs/2609.17633)</sup>在卡迪夫大学运筹学准教授、《图着色指南》（施普林格，2021）作者里德·刘易斯（Rhyd Lewis）报告的一项实证比较中，DSatur在随机图上产生的结果显著优于普通贪心算法。<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S0167637724001214)</sup><sup> • </sup><sup>[20](https://doi.org/10.1007/978-3-030-81054-2)</sup>在一次社区基准比较中，威尔士-鲍威尔和DSATUR产生的颜色数低于普通贪心，但运行时间更长。<sup>[21](https://github.com/ahaad1/GraphColoring)</sup>

最近的工作继续在此基础上发展。SSLD算法（半定谱学习与DSATUR）通过类似于Lovász theta数所用的半定规划松弛来固定第一个颜色类，然后让DSATUR为其余部分着色；在超过1600个基准实例中，它在几乎所有情况下匹配或优于普通DSATUR，在1604个实例中的876个上使用更少颜色，中位运行时间约慢195倍。<sup>[9](https://arxiv.org/abs/2609.17633)</sup>

## References

1. [Daniel Brélaz (1979). New Methods to Color Vertices of a Graph. Communications of the ACM 22(4): 251–256.](https://dblp.org/rec/journals/cacm/Brelaz79.html)
2. [NaughtFound/DSatur README, GitHub](https://github.com/NaughtFound/DSatur/blob/main/README.md)
3. [N. Yekezare, M. Zohrehbandian, M. Maghasedi, F. Bonomo-Braberman (2024). Optimality of DSatur algorithm on chordal graphs. Operations Research Letters 57.](https://www.sciencedirect.com/science/article/abs/pii/S0167637724001214)
4. [Furini, F. et al. DSATUR-based Branch and Bound (manuscript with state-of-the-art review), Optimization Online](https://optimization-online.org/wp-content/uploads/2015/10/5159.pdf)
5. [DSatur Algorithm for Graph Coloring, GeeksforGeeks](https://www.geeksforgeeks.org/dsa/dsatur-algorithm-for-graph-coloring/)
6. [Daniel Brélaz (1979). New methods to color the vertices of a graph (PDF), University of Nebraska–Lincoln mirror](https://cse.unl.edu/~choueiry/Documents/brelaz.pdf)
7. [Pablo San Segundo (2012). A new DSATUR-based algorithm for exact vertex coloring. Computers & Operations Research 39(7): 1724–1733.](https://www.sciencedirect.com/science/article/pii/S0305054811002966)
8. [strategy_saturation_largest_first, NetworkX 2.8.8 documentation](https://networkx.org/documentation/networkx-2.8.8/reference/algorithms/generated/networkx.algorithms.coloring.strategy_saturation_largest_first.html)
9. [Adam Nouira, Lucas Isenmann (2026). One Color Preprocessing Improves DSATUR. arXiv:2609.17633.](https://arxiv.org/abs/2609.17633)
10. [iamademar/dsatur-vs-cpsat, GitHub](https://github.com/iamademar/dsatur-vs-cpsat)
11. [R. M. R. Lewis, Guide to Graph Colouring: Algorithms and Applications (excerpt), Springer](https://manuals.plus/m/46fb2e3883d25cef498d7d5dd7dad7251c2f3680828975a5774ebfe6ecd27fd7)
12. [dblp: Konrad Piwakowski (The smallest hard-to-color graph for algorithm DSATUR, Discrete Mathematics 236(1–3): 151–165, 2001)](https://dblp.org/pid/p/KonradPiwakowski)
13. [Fabio Furini, Combinatorial Optimization course notes: Vertex coloring, the DSATUR branch-and-bound](https://fabiofurini.github.io/combinatorial-optimization/specialized-algorithms/dsatur-branch-and-bound/)
14. [Méndez-Díaz et al. An exact DSatur-based algorithm for the Equitable Coloring Problem. arXiv:1405.7011.](https://arxiv.org/abs/1405.7011)
15. [Swapnil Biswas et al. (2023). Graph Coloring in University Timetable Scheduling. IJISA 15(3): 16–32.](https://www.mecs-press.org/ijisa/ijisa-v15-n3/v15n3-2.html)
16. [Barbosa et al. (2024). Estudo de Coloração de Grafos Aplicado ao Problema de Alocação de Horários. ERCEMAPI.](https://sol.sbc.org.br/index.php/ercemapi/article/view/30179)
17. [Gregory J. Chaitin et al. (1981). Register allocation via coloring. Computer Languages 6(1): 47–57.](https://www.sciencedirect.com/science/article/pii/0096055181900485)
18. [Essentials of Compilation (PDF), chapter on saturation-based greedy register allocation](https://brinckerhoff.org/clements/2194-csc431/essentials-of-compilation.pdf)
19. [networkx.algorithms.coloring.greedy_coloring source, NetworkX 1.10 documentation](https://networkx.org/documentation/networkx-1.10/_modules/networkx/algorithms/coloring/greedy_coloring.html)
20. [R. M. R. Lewis (2021). Guide to Graph Colouring: Algorithms and Applications. Springer.](https://doi.org/10.1007/978-3-030-81054-2)
21. [ahaad1/GraphColoring, GitHub](https://github.com/ahaad1/GraphColoring)

---
*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 › Computational graph problems and algorithms › Graph coloring algorithms

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/dsatur

English original: https://www.edgepedia.org/dsatur
