Why it matters

Register allocation in compilers uses graph coloring. Scheduling problems reduce to coloring. Understanding enables applications.

Advertisement

The architecture

Chromatic number χ(G): minimum colors needed.

NP-hard in general. Polynomial for special graphs (planar, bipartite).

Graph coloring approachAssign colorto vertexCheck neighborsno color conflictRepeatgreedy or backtrackGreedy: order vertices, pick smallest color; heuristic ordering matters
Coloring algorithms.
Advertisement

How it works end to end

Greedy: order vertices; for each, pick smallest color not used by neighbors. Depends on order.

Welsh-Powell: order by degree descending. Often near-optimal.

DSatur: pick vertex with most colored neighbors next. Good heuristic.

Backtracking: for exact optimum on small graphs.

Register allocation: interference graph coloring. K colors = K registers.