🧩 Constraint Solving POTD:Graph Coloring #26868
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Constraint Solving — Problem of the Day. A newer discussion is available at Discussion #27186. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Category: Classic CSP | Date: 2026-04-17
Problem Statement
Graph coloring asks: given a graph
G = (V, E), assign a color from a set{1, ..., k}to each vertex such that no two adjacent vertices share the same color. The chromatic numberχ(G)is the minimumkfor which this is possible.Concrete Instance — The Petersen Graph (10 vertices, 15 edges)
Label the vertices
0–9. The outer pentagon connects0–1–2–3–4–0; the inner pentagram connects5–7–9–6–8–5; spokes connect0–5, 1–6, 2–7, 3–8, 4–9.Input: adjacency list (or matrix), number of colors
kOutput: an assignment
color: V → {1..k}satisfying all edge constraints, or UNSAT if none exists.Why It Matters
χ ≤ 4for any planar map.Modeling Approaches
Approach 1 — Constraint Programming (CP)
Decision variables:
color[v] ∈ {1..k}for each vertexv ∈ VConstraints:
Global constraint (optional):
Wrap with
alldifferentover cliques to tighten propagation.Trade-offs:
Approach 2 — Mixed-Integer Programming (MIP)
Decision variables:
x[v,c] ∈ {0,1}— 1 if vertexvgets colorcy[c] ∈ {0,1}— 1 if colorcis used (for minimization)Constraints:
Trade-offs:
Example Model — MiniZinc (CP)
For the Petersen graph with
k=3, MiniZinc finds a valid 3-coloring instantly.To find
χ(G), wrap in a minimize objective or iteratekfrom 1 upward.Key Techniques
1. Symmetry Breaking
Colors are interchangeable — swapping all red/blue vertices yields another valid solution. This creates huge amounts of value symmetry. Classic fixes:
color[1] ≤ color[2] ≤ first-use ordercolor[v] ≤ 1 + Σ_{u < v, (u,v) ∈ E} 1(cannot introduce a new color unless forced by a neighbor)These constraints can reduce the search space by a factor of
k!.2. DSATUR Heuristic (Variable Ordering)
DSATUR (Degree of SATURation) orders vertices by the number of distinct colors already used in their neighborhood — the most constrained vertex first. Combined with backtracking, this is among the strongest complete algorithms known for moderate-sized graphs.
3. Clique-Based Lower Bounds & Propagation
Any clique (fully-connected subgraph) requires as many colors as it has vertices:
ω(G) ≤ χ(G). Finding large cliques (itself NP-hard, but approximable) gives a tight lower bound onkand generates powerful clique constraints that propagate arc consistency far more efficiently than individual edge ≠ constraints.Challenge Corner
References
Beta Was this translation helpful? Give feedback.
All reactions