Graph Coloring: Crayons, Conflicts, and the Chromatic Number

Posted on July 10, 2026 by "GraphArena Team"

Introduction

Imagine you are a teacher arranging seating for a school exam. Some students are friends and will copy off each other — those students cannot sit in adjacent seats. You want to label every seat with a desk color so that no two friends share the same color. The minimum number of colors you need is an intrinsic property of the friendship network — and computing it is exactly what Graph Coloring is about.

Graph coloring is one of the most visually intuitive yet mathematically deep topics in graph theory. It connects directly to scheduling, map-making, register allocation in compilers, and one of the most famous theorems in all of mathematics: the Four Color Theorem.

In this post we will build the theory from scratch — from the Golden Rule through the chromatic number, famous graph families, greedy coloring, and real-world applications.


The Golden Rule of Graph Coloring

Definition

A proper vertex coloring of a graph is an assignment of a color to every vertex such that:

In words: no two adjacent vertices may share the same color.

This is the single rule that governs everything in graph coloring. The “colors” are just labels — mathematically they are elements of the set .

A graph is -colorable if there exists a proper coloring that uses at most colors.

Why Not Just Give Every Vertex a Different Color?

You always can — if your graph has vertices, you can trivially assign each one its own unique color and satisfy the Golden Rule. But that is not interesting or useful. The real question is: what is the minimum number of colors needed?


-Colorability

The variable counts how many colors are in our palette.

1-Colorable: The Hermits

When can a single color suffice? If you assign every vertex the same color, then any edge would connect two identically colored vertices — a violation. So:

Theorem: A graph is -colorable if and only if it has no edges (every vertex is isolated).

Five isolated vertices — no edges, no conflicts. Every vertex gets the same color. .

2-Colorable: The Bipartite Callback

Two colors mean we split vertices into two groups where all edges cross between them. That is exactly the definition of a bipartite graph from Post 08!

Theorem: A graph is -colorable if and only if it is bipartite.

Set (red) and Set (blue). Every edge connects red to blue — no two red vertices are adjacent, no two blue vertices are adjacent. This is a valid 2-coloring, and it is valid because the graph is bipartite.

Proof sketch:
- () If a 2-coloring exists, the two color classes form the bipartition.
- () If the graph is bipartite with partition , color with color 1 and with color 2.

3-Colorable: The Triangle

Consider — the triangle. Every vertex is adjacent to every other vertex, so every pair of vertices needs a different color.

  • (red) is adjacent to and — so and cannot be red.
  • (blue) is adjacent to — so cannot be blue either.
  • must be a third color: green.

. No matter how you try, two colors always fail on a triangle because it contains an odd cycle of length 3.


The “More is Easy” Rule

Here is a simple but important logical observation:

Theorem: If a graph is -colorable, then it is also -colorable for any .

Proof: Take any valid -coloring. Pick any single vertex and recolor it with a brand new color not used anywhere else. Since the new color appears nowhere among ’s neighbors, no conflict is created. The graph is now -colorable. Repeat for more extra colors.

Example: The even cycle (a square) is 2-colorable. Give the graph a 2-coloring with red and blue, then swap one vertex’s red for yellow. You now have a valid 3-coloring of the same graph.

with alternating red–blue. Since is an even cycle (bipartite), the alternation closes perfectly — .

The consequence: claiming a graph is -colorable is trivial. We care about the minimum.


The Chromatic Number

Definition

The chromatic number (pronounced “kai of G”) is the minimum number of colors needed for a proper coloring of .

A graph with is called a -chromatic graph.

Finding in general is computationally hard (NP-complete), but for structured graph families we can determine it exactly.

Key Lower Bound: Clique Number

A clique in a graph is a set of vertices that are all mutually adjacent (i.e., a complete subgraph). If contains a clique of size — written — then every vertex in that clique needs its own color:

This is our best simple lower bound. For example, the triangle inside any graph forces .

Note: The inequality can be strict. There exist triangle-free graphs () with arbitrarily large chromatic number. These are called Mycielski graphs — but that topic belongs to advanced graph theory.


Chromatic Numbers of Famous Graph Families

1. Empty Graph ()

No edges at all. Every vertex is isolated.

2. Complete Graph ()

Every vertex is adjacent to every other vertex. No two vertices can ever share a color.

with 4 vertices: each gets a unique color (red, blue, green, purple).

is the worst-case graph for coloring: it requires the maximum possible number of colors for its size.

3. Cycle Graphs ()

Vertices arranged in a ring, each adjacent to exactly two neighbors.

Even cycles ( — any cycle with an even number of vertices):

Even cycles are bipartite. Alternate two colors around the ring — the pattern closes perfectly because there is an even number of steps.

Odd cycles ( — any cycle with an odd number of vertices):

Alternate two colors (say red–blue) around the ring. When you reach the last vertex, it is adjacent to vertex 1 (red) and vertex (blue on even cycle). With an odd count, vertices 1 and the last vertex are both forced to be the same color — a conflict. A third color is needed for the last vertex.

coloring: vertices 1 (red), 2 (blue), 3 (red), 4 (blue), 5 — forced to be green because 5 is adjacent to both 1 (red) and 4 (blue). .

Summary:

Cycle Even or Odd
(triangle) Odd 3
(square) Even 2
(pentagon) Odd 3
(hexagon) Even 2
, even Even 2
, odd Odd 3

This also gives a clean restatement of the bipartite characterization:

Theorem: A cycle graph is bipartite if and only if is even.

4. Bipartite Graphs (General)

Theorem: is bipartite .

More precisely:
- if is bipartite and has no edges (the empty graph).
- if is bipartite and has at least one edge.

Star graphs fall here: the central hub is one color, all leaf vertices share another. for .

5. Wheel Graphs ()

A wheel graph is constructed by taking a cycle and adding one hub vertex connected to every vertex on the outer ring.

= hub + outer . The hub (green) is adjacent to all outer vertices. The outer ring is (even), colored red–blue–red–blue. The hub cannot share red or blue, so it gets green. Total: .

= hub + outer . The outer ring is (odd), requiring 3 colors. The hub is adjacent to all 5 outer vertices — it is adjacent to all 3 colors used on the ring — so it needs a 4th color (purple). Total: .

General rule for wheel graphs:

Outer ring Hub needs
Even cycle 2 1 new color 3
Odd cycle 3 1 new color 4

The hub always needs exactly one more color than the outer cycle requires.


Greedy Coloring

Finding the optimal chromatic number is NP-complete in general, but a simple greedy algorithm gives a practical upper bound.

The Algorithm

Process vertices in some fixed order . For each vertex :

  1. Look at all neighbors of that have already been colored.
  2. Assign to the smallest-numbered color not already used by any of its colored neighbors.

This is called the First-Fit or Sequential Greedy coloring.

Demonstration

Processing order:

Step Vertex Colored neighbors Colors used by them Assigned color
1 none Color 1 (red)
2 {red} Color 2 (blue)
3 , {red, blue} Color 3 (green)
4 {blue} Color 1 (red) ← reuses!
5 , {green, red} Color 2 (blue) ← reuses!

Result: 3 colors total. for this graph (verified by the triangle ).

Greedy Bound

Theorem: For any graph with maximum degree :

Every vertex has at most neighbors, so the greedy algorithm needs at most colors (it can always find an unused color from the first ).

Brooks’ Theorem (1941) tightens this to for all connected graphs that are not complete graphs or odd cycles. So is tight only for and .

Order Matters

The greedy algorithm is order-dependent: a bad vertex ordering can use more colors than necessary.

Example: The bipartite graph has . If vertices are ordered perfectly (all of set first, then all of ), greedy uses 2 colors. But if ordered (alternating), greedy still uses 2 because only sees and picks color 2. However, on other graphs, adversarial orderings can force up to colors even when . The greedy algorithm never under-estimates , but it can over-estimate it.


The Four Color Theorem

Perhaps the most famous theorem in graph theory — and one of the first major theorems proved by computer:

Four Color Theorem (Appel & Haken, 1976): Every planar graph is 4-colorable. In other words, any map drawn on a flat surface can be colored with at most 4 colors so that no two adjacent regions share a color.

Translating Maps to Graphs

The map coloring problem is a graph coloring problem in disguise:
- Each region (state, country) becomes a vertex.
- Two vertices are connected by an edge if the corresponding regions share a border.

The resulting graph is always planar (can be drawn without edge crossings), and the Four Color Theorem guarantees for all planar graphs.

Five regions arranged as a ring with one central region. The central region borders all five outer regions (each a different color). No two outer regions adjacent to each other in the ring can share the same color as their neighbor. Four colors suffice to color the entire map.

Historical Note

The Four Color Conjecture was posed in 1852 by Francis Guthrie while coloring a map of England. It resisted proof for 124 years. Appel and Haken’s 1976 proof was controversial because it relied on a computer to verify 1,936 reducible configurations — the first major theorem proved with computer assistance. The proof has since been verified and simplified, but the theorem remains a landmark in mathematics.

The number 3 is not always enough: The map of the United States, for instance, requires 4 colors — the states of Nevada, Arizona, Utah, Colorado, and New Mexico form a structure requiring 4.


Practice Problems

Problem 1: Determine the Chromatic Number

Question: A graph has 6 vertices with edges forming two triangles that share one common edge (AB). Vertices: where is one triangle and is another. What is ?

Click to reveal solution

List the adjacencies:

  • Triangle 1: $A$–$B$, $B$–$C$, $C$–$A$
  • Triangle 2: $A$–$B$, $B$–$D$, $D$–$A$

Both triangles share edge $A$–$B$, so the unique edges are: $AB, BC, CA, BD, DA$.

Start coloring: $A$ = red. $B$ is adjacent to $A$, so $B$ = blue. $C$ is adjacent to $A$ (red) and $B$ (blue), so $C$ = green. $D$ is adjacent to $A$ (red) and $B$ (blue), so $D$ = green ← $D$ and $C$ are not adjacent, so they can share green.

$\chi(G) = 3$. The two triangles force 3 colors, but $C$ and $D$ (non-adjacent) can share the third color.

Problem 2: Odd vs. Even Cycle

Question: Cycles and — which requires more colors? What is the chromatic number of each?

Click to reveal solution

$C_7$: 7 vertices, odd number. Odd cycles require 3 colors. $\chi(C_7) = 3$.

$C_{12}$: 12 vertices, even number. Even cycles are bipartite, requiring 2 colors. $\chi(C_{12}) = 2$.

$C_7$ requires more colors ($\chi = 3$ vs $\chi = 2$).

Problem 3: Greedy Coloring

Question: Apply greedy coloring to (the complete graph on 4 vertices , all pairs connected) in order . How many colors does greedy use? Is it optimal?

Click to reveal solution

Step 1: $A$ → no colored neighbors → color 1 (red).

Step 2: $B$ → neighbor $A$ has color 1 → color 2 (blue).

Step 3: $C$ → neighbors $A$ (red), $B$ (blue) → color 3 (green).

Step 4: $D$ → neighbors $A$ (red), $B$ (blue), $C$ (green) → color 4 (purple).

Greedy uses 4 colors. Since $K_4$ is a 4-clique, $\chi(K_4) = 4$. Yes, greedy is optimal here.

In general greedy is optimal on complete graphs — there is no ordering that can do better because every vertex is a neighbor of every previous vertex.

Problem 4: Chromatic Number from Clique

Question: A graph has a clique of size 5 (i.e., as a subgraph). What can you conclude about ?

Click to reveal solution

Since $G$ contains $K_5$, the clique number satisfies $\omega(G) \geq 5$.

The clique lower bound gives $\chi(G) \geq \omega(G) \geq 5$.

Conclusion: $\chi(G) \geq 5$. The graph needs at least 5 colors.

We cannot conclude $\chi(G) = 5$ without more information — the rest of the graph might require even more colors.

Problem 5: Wheel Graph

Question: What is ? ( has 8 vertices: a hub and an outer ring of 7 vertices.)

Click to reveal solution

$W_8$ has 8 total vertices, so the outer ring is $C_7$ (7 vertices, an odd cycle).

$\chi(C_7) = 3$ (odd cycle).

The hub is adjacent to all 7 outer vertices, which use all 3 colors. The hub needs a 4th color not used on the ring.

$\chi(W_8) = 4$.

Problem 6: Exam Scheduling

Question: A university has 5 courses: Math, CS, Physics, History, English. The following pairs of courses share students (and thus cannot be scheduled at the same time): Math–CS, Math–Physics, Math–English, CS–Physics, CS–History, Physics–History, History–English. What is the minimum number of exam time slots needed?

Click to reveal solution

Model as a graph: vertices = courses, edges = shared-student pairs.

Find $\chi$ of this conflict graph.

Look for cliques: Math, CS, Physics are mutually connected (Math–CS, Math–Physics, CS–Physics) → triangle → $\chi \geq 3$.

Try 3-coloring:

  • Math → slot 1 (red)
  • CS → slot 2 (blue) [adjacent to Math]
  • Physics → slot 3 (green) [adjacent to Math and CS]
  • History → slot 1 (red) [adjacent to CS (blue) and Physics (green) — red is free]
  • English → slot 2 (blue) [adjacent to Math (red) and History (red) — blue is free]

3 time slots suffice. $\chi = 3$, so 3 is the minimum.


Summary Table

Graph Family Reason
Empty graph 1 No edges — no conflicts
Any bipartite graph (with edges) 2 Two color classes, edges only cross between them
Triangle 3 Smallest odd cycle / clique
Even cycle 2 Bipartite — alternating 2-coloring works
Odd cycle 3 Not bipartite — last vertex forces a 3rd color
Complete graph Every vertex adjacent to every other
Wheel , even 3 Even outer ring (2 colors) + hub (1 more)
Wheel , odd 4 Odd outer ring (3 colors) + hub (1 more)

Key inequalities:

The clique number is a lower bound; is an upper bound (greedy bound). Brooks’ Theorem tightens the upper bound to for most graphs.


Real-World Applications

Exam and Meeting Scheduling

If vertices are events (exams, meetings) and edges connect events that share a participant, then a proper -coloring assigns events to non-overlapping time slots with no participant double-booked. The chromatic number is the minimum number of slots needed.

Math and History can share slot 1 because no student takes both. CS and English share slot 2. Physics takes slot 3 alone. Three slots suffice for five exams — that is the chromatic number of the conflict graph.

Register Allocation in Compilers

When a compiler translates high-level code to machine code, it must assign program variables to CPU registers. Two variables that are “live” at the same time cannot share a register. Build an interference graph — vertices are variables, edges connect variables live simultaneously — and color it. The chromatic number is the minimum number of registers needed; extra variables must be “spilled” to slower memory.

Sudoku Puzzles

Every solved Sudoku grid is a graph coloring with . The 81 cells are vertices. Two cells are connected by an edge if they share a row, column, or box. Solving Sudoku is finding a proper 9-coloring of this specific graph.

Map Coloring and the Four Color Theorem

Any political map on a flat surface (a planar graph) can be colored with at most 4 colors. This is a theoretical guarantee — in practice, most real maps require at most 4 and many need only 3.

Wireless Frequency Assignment

In a cellular network, adjacent cell towers (base stations) cannot broadcast on the same frequency or they will interfere. Model towers as vertices and interference relationships as edges — the chromatic number is the minimum number of distinct frequencies needed. Reducing directly reduces spectrum usage and cost.


Key Takeaways

  1. A proper coloring assigns colors to vertices so that no two adjacent vertices share a color. The variable denotes the number of colors used.
  2. A graph is -colorable if a proper coloring exists with at most colors. If -colorable, it is also -colorable for any .
  3. The chromatic number is the minimum for which is -colorable. Finding it exactly is NP-complete in general.
  4. -colorable: only the empty graph (no edges). -colorable: exactly the bipartite graphs.
  5. Even cycles () have ; odd cycles () have . A cycle is bipartite iff it is even.
  6. Complete graphs need the most colors: . Wheel graphs follow the outer cycle plus one: (even outer ring) or (odd outer ring).
  7. The clique number gives a lower bound: . Greedy coloring gives an upper bound: .
  8. Greedy coloring assigns the smallest available color to each vertex in sequence — fast and practical, but order-dependent and not always optimal.
  9. The Four Color Theorem (1976): every planar graph has . Any flat map can be colored with 4 colors.
  10. Graph coloring models real problems including exam scheduling, register allocation, frequency assignment, and map coloring.

Explore Further

Use the GraphArena Playground to experiment:

  • Build the triangle and verify that 2-coloring always fails — try every possible 2-assignment.
  • Build and side by side. Trace through the alternating 2-coloring on each: see exactly where forces a third color at the closing edge.
  • Build (hub + ) and (hub + ). Color the outer ring first, then try to color the hub — observe that it needs one extra color.
  • Try the greedy algorithm on : order vertices and watch how greedy picks colors. Then reorder all ’s first and compare.
  • Build a 5-clique () and confirm that — every vertex needs its own color.
  • Model the exam scheduling example: 5 courses, 7 conflict edges. Find a 3-coloring and verify no two conflicting courses share a slot.

The chromatic number sits at the intersection of algorithms, combinatorics, and applications — a single number that captures the essential “conflict structure” of any graph.