You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Graph Coloring asks: given a graph G = (V, E) and k colors, assign one color to each vertex so that no two adjacent vertices share the same color. The chromatic numberΟ(G) is the minimum k for which this is possible.
Question: Can we color this graph with 3 colors? Answer: Yes β Ο(Petersen) = 3. A valid coloring: {0βR, 1βG, 2βB, 3βG, 4βB, 5βG, 6βR, 7βR, 8βB, 9βB} (verify: every edge has distinct endpoints).
Input: Graph G, integer k Output: A mapping color: V β {1..k} satisfying all edge constraints, or UNSAT
Why It Matters
Register Allocation: Compilers model variables as graph vertices and register conflicts as edges; coloring directly yields a register assignment. A spill occurs when Ο > #registers``.
Timetabling & Scheduling: Exams sharing students are adjacent; colors are time-slots. Frequency assignment in wireless networks works identically.
VLSI Design: Layers in circuit routing and via minimization reduce to graph coloring variants.
Modeling Approaches
Approach 1 β Constraint Programming (CP)
Decision variables:color_v β {1..k} for each v β V
Constraints:
β (u,v) β E : color_u β color_v
Global constraint:allDifferent can be applied to cliques in the graph for stronger propagation.
Symmetry breaking: Fix color_{v_0} = 1, and for each new vertex v_i (in BFS order) require color_{v_i} β€ 1 + max(color_{v_j} : j < i). This eliminates permutations of the color palette.
Trade-offs: CP propagation via arc consistency (AC-3 / AC-4) prunes domains aggressively. The notEqual constraint is lightweight, but clique-based allDifferent provides stronger bounds on k.
Approach 2 β SAT Encoding
Variables: Boolean x_{v,c} = "vertex v gets color c"
At-least-one per vertex:
β v : x_{v,1} β¨ x_{v,2} β¨ ... β¨ x_{v,k}
At-most-one per vertex (pairwise):
β v, c1 < c2 : Β¬x_{v,c1} β¨ Β¬x_{v,c2}
Edge constraints:
β (u,v) β E, β c : Β¬x_{u,c} β¨ Β¬x_{v,c}
Total clauses: |V| (ALO) + |V|Β·k(k-1)/2 (AMO) + |E|Β·k (edges)
Trade-offs: Modern CDCL solvers (MiniSat, CaDiCaL) handle this well for moderate k. The AMO encoding blows up for large k; commander-variable or product encodings can compress it. SAT is ideal when you need a yes/no answer quickly.
Approach 3 β Mixed-Integer Programming (MIP)
Variables:x_{v,c} β {0,1}, w_c β {0,1} (is color c used?)
Minimize:β_c w_c (minimize number of colors used)
Constraints:
β_c x_{v,c} = 1 β v (exactly one color)
x_{u,c} + x_{v,c} β€ w_c β (u,v)βE, β c
x_{v,c} β€ w_c β v, c
Trade-offs: MIP naturally optimizes Ο(G) rather than just deciding feasibility. LP relaxation provides lower bounds; clique inequalities tighten the LP gap substantially.
Example Model β MiniZinc (CP)
int: n; % number of verticesint: k; % number of colorsint: m; % number of edgesarray[1..m, 1..2] ofint: edges;
array[1..n] ofvar1..k: color;
% No two adjacent vertices share a colorconstraintforall(ein1..m)(
color[edges[e,1]] !=color[edges[e,2]]
);
% Symmetry breaking: colors used in non-decreasing orderconstraintcolor[1] =1;
constraintforall(vin2..n)(
color[v] <=1+max(color[u] |uin1..v-1)
);
solvesatisfy;
For the Petersen graph: set n=10, k=3, m=15 and provide the edge list. The solver returns a valid 3-coloring in milliseconds.
Key Techniques
1. Propagation β Bounds on Cliques
The clique lower bound states Ο(G) β₯ Ο(G) (clique number). Finding a large clique (even a maximal one via greedy) tightens the domain of k before search begins. In CP, posting allDifferent over a clique prunes all k < |clique|.
At each step, color the uncolored vertex with the highest saturation (most distinct colors in its neighborhood).
Tie-break on degree.
Often finds optimal or near-optimal colorings without backtracking.
Used both standalone and as a branching strategy inside CP/SAT solvers.
3. Symmetry Breaking via Value Ordering
Permuting the color labels gives k! equivalent solutions. The lex-leader constraint eliminates these: ensure the color assignment is lexicographically minimal among all equivalent solutions. In practice, the incremental symmetry-breaking above (color v_i β€ 1 + max previous colors) achieves this efficiently.
The fractional chromatic numberΟ_f(G) is defined via a linear programming relaxation and always satisfies Ο_f(G) β€ Ο(G).
Can you write the LP relaxation for the SAT-based coloring formulation and identify what Ο_f represents geometrically?
For the Petersen graph, Ο_f = 5/2. How large is the integrality gap relative to Ο = 3?
Can you encode a list coloring variant β where each vertex v has its own allowed color set L(v) β {1..k} β as a minor modification of the CP model above?
Rossi, F., van Beek, P., Walsh, T. (eds.) (2006).Handbook of Constraint Programming, Elsevier. β Chapter 2 covers CSP foundations; Chapter 7 covers graph problems.
Mehrotra, A. & Trick, M. A. (1996). "A Column Generation Approach for Graph Coloring." INFORMS Journal on Computing, 8(4):344β354. β Branch-and-price approach achieving state-of-the-art MIP results.
Sinz, C. (2005). "Towards an Optimal CNF Encoding of Boolean Cardinality Constraints." CP 2005, LNCS 3709. β The AMO encoding options referenced in the SAT model.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Date: 2026-04-20 | Category: Classic CSP
Problem Statement
Graph Coloring asks: given a graph
G = (V, E)andkcolors, assign one color to each vertex so that no two adjacent vertices share the same color. The chromatic numberΟ(G)is the minimumkfor which this is possible.Concrete Instance β Petersen Graph (10 vertices, 15 edges)
Question: Can we color this graph with 3 colors?
Answer: Yes β
Ο(Petersen) = 3. A valid coloring:{0βR, 1βG, 2βB, 3βG, 4βB, 5βG, 6βR, 7βR, 8βB, 9βB}(verify: every edge has distinct endpoints).Input: Graph
G, integerkOutput: A mapping
color: V β {1..k}satisfying all edge constraints, or UNSATWhy It Matters
Ο >#registers``.Modeling Approaches
Approach 1 β Constraint Programming (CP)
Decision variables:
color_v β {1..k}for eachv β VConstraints:
Global constraint:
allDifferentcan be applied to cliques in the graph for stronger propagation.Symmetry breaking: Fix
color_{v_0} = 1, and for each new vertexv_i(in BFS order) requirecolor_{v_i} β€ 1 + max(color_{v_j} : j < i). This eliminates permutations of the color palette.Trade-offs: CP propagation via arc consistency (AC-3 / AC-4) prunes domains aggressively. The
notEqualconstraint is lightweight, but clique-basedallDifferentprovides stronger bounds onk.Approach 2 β SAT Encoding
Variables: Boolean
x_{v,c}= "vertexvgets colorc"At-least-one per vertex:
At-most-one per vertex (pairwise):
Edge constraints:
Total clauses:
|V|(ALO) +|V|Β·k(k-1)/2(AMO) +|E|Β·k(edges)Trade-offs: Modern CDCL solvers (MiniSat, CaDiCaL) handle this well for moderate
k. The AMO encoding blows up for largek; commander-variable or product encodings can compress it. SAT is ideal when you need a yes/no answer quickly.Approach 3 β Mixed-Integer Programming (MIP)
Variables:
x_{v,c} β {0,1},w_c β {0,1}(is colorcused?)Minimize:
β_c w_c(minimize number of colors used)Constraints:
Trade-offs: MIP naturally optimizes Ο(G) rather than just deciding feasibility. LP relaxation provides lower bounds; clique inequalities tighten the LP gap substantially.
Example Model β MiniZinc (CP)
For the Petersen graph: set
n=10, k=3, m=15and provide the edge list. The solver returns a valid 3-coloring in milliseconds.Key Techniques
1. Propagation β Bounds on Cliques
The clique lower bound states
Ο(G) β₯ Ο(G)(clique number). Finding a large clique (even a maximal one via greedy) tightens the domain ofkbefore search begins. In CP, postingallDifferentover a clique prunes allk < |clique|.2. DSATUR Heuristic
DSATUR (BrΓ©laz 1979) is a powerful variable-ordering heuristic:
3. Symmetry Breaking via Value Ordering
Permuting the color labels gives
k!equivalent solutions. The lex-leader constraint eliminates these: ensure the color assignment is lexicographically minimal among all equivalent solutions. In practice, the incremental symmetry-breaking above (colorv_i β€ 1 + max previous colors) achieves this efficiently.Challenge Corner
References
Beta Was this translation helpful? Give feedback.
All reactions