A Bit of History
Greedy coloring is the natural first attempt at any coloring problem, but its weakness — extreme sensitivity to vertex order — motivated better orderings. In 1967, Dominic Welsh and Martin Powell published a simple but effective fix: sort vertices by descending degree before coloring greedily, guaranteeing a coloring using at most $\Delta + 1$ colors matching known upper bounds. Over a decade later, Daniel Brélaz introduced DSatur (Degree of Saturation) in his 1979 paper "New Methods to Color the Vertices of a Graph", replacing the static degree ordering with a dynamic one that adapts as coloring proceeds — DSatur remains one of the strongest general-purpose coloring heuristics in practical use today, over four decades later.
Greedy Coloring: Arbitrary Order
The simplest possible approach: process vertices in any fixed order (even arbitrary), and assign each vertex the lowest-numbered color not already used by any already-colored neighbor.
Guarantee & Weakness
Greedy coloring always uses at most $\Delta + 1$ colors, where $\Delta$ is the maximum degree — but the order of vertices dramatically affects the result. A poorly chosen order can force greedy coloring to use far more colors than the true chromatic number $\chi(G)$ requires; a well-chosen order can sometimes achieve the optimum. This sensitivity motivates the smarter orderings below.
Welsh-Powell: Degree-Descending Order
Sort all vertices once, by descending degree, before running the greedy pass. Intuition: high-degree vertices have the most constraints (most neighbors competing for colors), so coloring them first, while the fewest colors are already "used up," gives them the best chance of reusing an early color instead of forcing a brand-new one.
DSatur: Saturation Degree Order
Welsh-Powell's ordering is static — computed once, up front. DSatur instead recomputes the "most urgent" vertex to color at every step, using a value called saturation degree: the number of distinct colors already used among a vertex's neighbors (not just neighbor count).
- At each step, pick the uncolored vertex with the highest saturation degree (most distinct neighbor colors already "blocking" it) — ties broken by highest remaining degree.
- Assign it the lowest available color not used by any neighbor.
- Update saturation degrees of its neighbors, and repeat.
Because saturation degree changes dynamically as coloring proceeds (a vertex becomes more constrained as more of its neighbors get colored), DSatur reacts to the evolving state of the coloring rather than committing to a fixed plan upfront — this adaptivity is why it consistently outperforms Welsh-Powell in practice, especially on graphs with irregular degree distributions.
Worked Example
Star-like graph: center vertex 0 connected to 1, 2, 3, 4; plus an extra edge 1-2.
- Welsh-Powell order (by degree): vertex 0 (degree 4) first, then 1 and 2 (degree 2 each), then 3, 4 (degree 1 each). Color 0 = A. Color 1 = B (differs from 0). Color 2 = C (differs from 0 and 1, since 1-2 is an edge). Color 3 = B (only conflicts with 0). Color 4 = B. Total colors used: 3.
- DSatur: initially all saturation degrees are 0 except by raw degree tie-break, so vertex 0 (degree 4) colored first: A. Now 1, 2, 3, 4 each have saturation degree 1 (one neighbor colored A) — tie, break by degree: 1 and 2 have degree 2 (due to the 1-2 edge), pick 1: color B. Now vertex 2 has saturation degree 2 (sees both A from vertex 0 and B from vertex 1) — highest priority: color C. Vertices 3, 4 have saturation degree 1: color B. Same result here (3 colors), but DSatur's dynamic re-evaluation would diverge from Welsh-Powell on more irregular graphs.
Complexity Analysis
| Heuristic | Time Complexity | Color Guarantee |
|---|---|---|
| Greedy (arbitrary order) | $O(V + E)$ | $\leq \Delta + 1$ colors |
| Welsh-Powell | $O(V \log V + E)$ | $\leq \Delta + 1$ colors (often fewer in practice) |
| DSatur | $O(V^2)$ (naive) or $O((V+E)\log V)$ (with a priority queue) | Exact for bipartite & some structured classes; near-optimal in general |
Implementation
Real-World Applications
Register Allocation & Exam Timetabling
Compilers use graph coloring heuristics (typically Chaitin's algorithm, a variant built on greedy/DSatur ideas) to assign a limited number of physical CPU registers to a much larger set of program variables, treating variables that are "live" simultaneously as conflicting (adjacent) in an interference graph. Universities use these same heuristics to schedule exams: courses sharing students become adjacent vertices, and each color represents a distinct exam time slot, minimizing scheduling conflicts.
Exercises
- Construct a graph where a poor greedy vertex ordering uses far more colors than the chromatic number, while a good ordering achieves the optimum.
- Run DSatur and Welsh-Powell on the Petersen graph and compare the number of colors each produces.
- Prove that DSatur always finds the exact chromatic number on bipartite graphs.
- Challenge: Implement recursive largest first (RLF), another classical coloring heuristic, and compare its results against DSatur on a random graph benchmark.
Limitations
No Optimality Guarantee
None of these heuristics guarantee an optimal (minimum-color) coloring — they are polynomial-time approximations to an NP-hard problem. For applications requiring a provably minimum coloring, exact methods (backtracking, SAT-based, or ILP formulations) remain necessary, trading exponential worst-case time for a correctness guarantee.