A Short History of Coloring Heuristics
Graph coloring grew from a mathematical puzzle into a practical language for timetabling, resource assignment, and constraint processing. The heuristics in this article share one lineage: keep the fast first-fit rule, but become increasingly deliberate about which vertex is colored next.
The Shared Greedy Core
All three methods eventually perform the same local move: assign the smallest nonnegative color absent from the already-colored neighborhood. They differ only in the policy that supplies the next vertex.
Always feasible
On a loop-free graph, first-fit always finds some color. The output can be verified by checking $c(u)\ne c(v)$ for every edge.
An upper bound, not a proof of optimality
If the heuristic uses $q$ colors, then $\chi(G)\leq q$. It does not prove that $q$ is the smallest possible value.
Greedy Coloring: Arbitrary Order
Given an order $v_1,v_2,\ldots,v_n$, process one vertex at a time. When coloring $v_i$, look only at its already-colored neighbors and choose the smallest available color. Later vertices must adapt to earlier decisions; greedy never revisits a color once assigned.
Read the next vertex
The order may come from input, arrival time, a randomized shuffle, or another heuristic.
Mark forbidden colors
Collect the colors used by neighbors that have already been processed. Uncolored neighbors impose no restriction yet.
Choose first-fit
Assign the smallest color not in the forbidden set. A vertex of degree $d$ can forbid at most $d$ colors.
Why the $\Delta+1$ Bound Is Immediate
A vertex has at most $\Delta$ neighbors, so at most $\Delta$ distinct colors can be blocked when it is processed. Among colors $0,1,\ldots,\Delta$, at least one remains available.
Why Order Matters: One Graph, Two Outcomes
Consider the crown graph $K_{4,4}$ with the four matching edges $(a_i,b_i)$ removed. It is bipartite, so $\chi(G)=2$. Yet the interleaved order $a_1,b_1,a_2,b_2,a_3,b_3,a_4,b_4$ makes first-fit introduce a new color for every pair.
Welsh-Powell: Degree-Descending Order
Welsh–Powell replaces an arbitrary order with a static proxy for difficulty: sort vertices by descending degree, then apply first-fit. High-degree vertices participate in many constraints, so resolving them early often prevents a lightly constrained choice from consuming a useful color first.
The proxy has a blind spot: degree counts neighbors, not the different colors those neighbors already use. It also cannot distinguish vertices in a regular graph. Every crown-graph vertex above has degree three, so a stable degree sort preserves the bad interleaved order.
DSatur: Saturation Degree Order
DSATUR measures urgency directly. For an uncolored vertex $v$, define
$$\operatorname{sat}(v)=\left|\{c(u):u\in N(v),\;u\text{ is colored}\}\right|.$$
This counts distinct neighbor colors, not colored neighbors. Five red neighbors contribute saturation one; one red, one navy, and one teal neighbor contribute saturation three.
Select maximum saturation
Choose the uncolored vertex facing the largest number of blocked colors.
Break ties by remaining degree
Prefer the tied vertex with more neighbors still uncolored; use the vertex index only to make the implementation deterministic.
Assign first-fit and update
Use the smallest available color, then add it to the saturation sets of uncolored neighbors.
Worked Example
Use the crown graph from the SVG and deterministic ties by label. Arbitrary greedy and Welsh–Powell retain the interleaved order because every degree equals three. DSATUR instead creates the true bipartition.
| Method | Selection or order | Color sequence | Total |
|---|---|---|---|
| Greedy | $a_1,b_1,a_2,b_2,a_3,b_3,a_4,b_4$ | $0,0,1,1,2,2,3,3$ | 4 |
| Welsh–Powell | same stable order; every degree is 3 | $0,0,1,1,2,2,3,3$ | 4 |
| DSATUR | $a_1,b_2,a_3,b_1,a_2,a_4,b_3,b_4$ | $0,1,0,1,0,0,1,1$ | 2 |
This is not a proof that DSATUR always dominates degree ordering. It shows the information advantage of a dynamic priority: saturation observes how earlier colors interact, while degree alone never changes.
Choosing a Heuristic
Use arbitrary greedy when…
vertices arrive online, latency is critical, or an externally meaningful order already exists.
Use Welsh–Powell when…
you want a deterministic, inexpensive baseline with one preprocessing sort and no dynamic priority maintenance.
Use DSATUR when…
solution quality matters enough to spend quadratic time on a simple implementation, especially before exact search.
Use an exact method when…
you must prove optimality or feasibility with a fixed color budget. Feed it the heuristic coloring as an initial upper bound.
Complexity Analysis
Let $n=|V|$, $m=|E|$, and $\Delta$ be maximum degree. These bounds assume adjacency lists and a timestamp or set-based method for marking neighbor colors.
| Heuristic | Ordering cost | Total time | General guarantee |
|---|---|---|---|
| Greedy | none when order is given | $O(n+m)$ | valid coloring using at most $\Delta+1$ colors |
| Welsh–Powell | $O(n\log n)$ sort | $O(n\log n+m)$ | same $\Delta+1$ bound; no general optimality guarantee |
| DSATUR, simple scan | $O(n)$ selection repeated $n$ times | $O(n^2+m)$ average with hash sets | same $\Delta+1$ bound; exact on some graph classes |
A priority queue can reduce selection overhead in engineered DSATUR implementations, but saturation keys change dynamically and must be updated carefully. For teaching and moderate graphs, the $O(n^2+m)$ scan is compact, deterministic, and hard to get wrong.
Implementation
The implementations use the same conventions: a simple undirected adjacency list, deterministic label-based ties, first-fit color numbers beginning at zero, and the original Brélaz-style tie-break based on degree in the remaining uncolored graph.
Real-World Applications
Coloring is a useful abstraction whenever pairwise conflicts forbid two objects from sharing a resource. The heuristic minimizes colors only indirectly, so the graph and the meaning of a color must match the real constraints.
Exam timetabling
Courses are vertices, a shared student creates an edge, and colors represent time slots. Room capacity and preferred times require additional constraints beyond plain coloring.
Register allocation
Simultaneously live program values interfere. Colors represent physical registers; when too few registers exist, a compiler may spill selected values to memory and rebuild the graph.
Frequency assignment
Nearby transmitters that would interfere become adjacent. Colors model channels, while real deployments may also need weighted separation and geographic constraints.
Exact-solver warm starts
A fast heuristic gives an initial upper bound. Branch-and-bound, SAT, or ILP solvers can prune any search state that cannot improve it.
Validate Before You Trust the Count
The color count is meaningful only after checking feasibility. Scan every edge once and confirm its endpoints differ; then compute $1+\max_v c(v)$ for a nonempty graph.
Exercises
1. Generalize the crown example
For $K_{r,r}$ minus a perfect matching, prove that the interleaved order $a_1,b_1,\ldots,a_r,b_r$ makes first-fit use $r$ colors although the graph is bipartite.
2. Prove the universal bound
Show directly that every sequential first-fit ordering uses at most $\Delta+1$ colors. Construct a graph where all $\Delta+1$ are necessary.
3. Separate saturation from colored degree
Draw two uncolored vertices with the same number of colored neighbors but different saturation degrees. Which one does DSATUR prioritize, and why?
4. Benchmark tie-breaking
Compare static degree and remaining degree as the DSATUR tie-break on random graphs. Report valid color counts, runtimes, and enough seeds to make the experiment reproducible.
5. Add an optimality proof
Use the DSATUR coloring as an upper bound in an exact $k$-colorability search. Combine it with a clique lower bound and stop when the bounds meet.
Limitations
Feasible Does Not Mean Optimal
These are constructive heuristics, not general approximation algorithms with a promised ratio. They quickly produce valid colorings, but the gap between the returned count and $\chi(G)$ can be large on adversarial graphs.
- Ties are algorithmic choices: equal priorities are common. State the tie-break and keep it deterministic when reproducibility matters.
- Labels are arbitrary: color 0 is not better than color 1. Renaming colors preserves the same partition.
- Simple-graph assumptions matter: duplicate adjacency entries are harmless after normalization, but a self-loop makes proper coloring impossible.
- Dynamic graphs need maintenance: adding or removing an edge can invalidate a coloring; recomputation or an incremental recoloring strategy may be required.
- Extra constraints change the problem: capacities, preassigned colors, unavailable slots, and weighted conflicts require list coloring or a richer constraint model.