01 / 20

Graph Coloring
Concepts & Applications

Learn how to assign colors to vertices so that no two adjacent vertices share the same color, and discover why this idea powers scheduling, map coloring, and register allocation.

Discrete Mathematics

What Is Graph Coloring?

A graph coloring is an assignment of labels (called "colors") to each vertex of a graph such that no two adjacent vertices share the same color. Adjacent means they are connected by an edge.

A B C edge edge edge

Key Terminology

Proper Coloring
An assignment of colors to vertices where no two adjacent vertices share a color.
\( k \)-Coloring
A proper coloring that uses exactly \( k \) distinct colors or fewer.
\( \chi(G) \) : Chromatic Number
The smallest \( k \) such that graph \( G \) has a proper \( k \)-coloring.

Why Does It Matter?

Graph coloring is not just abstract: it models real-world constraint satisfaction. Any time you must assign resources so that conflicting items differ, you are solving a coloring problem.

Map Coloring
Color countries so bordering nations differ: this inspired the famous Four Color Theorem.
Exam Scheduling
Assign time slots to exams: students sharing two courses create an edge (conflict).
Register Allocation
Compilers assign CPU registers to variables; simultaneously live variables conflict.

The Chromatic Number \( \chi(G) \)

The chromatic number \( \chi(G) \) is the central quantity of interest. It answers: what is the fewest colors needed for a proper coloring of \( G \)?

\( C_5 \)
1 2 3 1 2 Odd Cycle
\( \chi(C_5) = 3 \)
3 colors needed (2 is impossible) Odd cycles always need 3 Even cycles need only 2

The Four Color Theorem

Every planar graph (a graph that can be drawn in the plane without edge crossings) can be properly colored with at most 4 colors.

Color 1 Color 2 Color 3 Color 4 Color 1

Bounds on \( \chi(G) \)

1
Clique lower bound: \( \chi(G) \geq \omega(G) \). A complete subgraph on \( k \) vertices demands \( k \) colors.
2
Greedy upper bound: \( \chi(G) \leq \Delta(G) + 1 \), where \( \Delta(G) \) is the maximum degree. This always works with a greedy algorithm.
3
Brooks' Theorem: If \( G \) is connected, not a complete graph, and not an odd cycle, then \( \chi(G) \leq \Delta(G) \).
4
Bipartite test: \( \chi(G) = 2 \) if and only if \( G \) is bipartite (no odd cycles).

Bipartite vs Non-Bipartite

Bipartite (Even Cycle) \( \chi = 2 \) Non-Bipartite (Odd Cycle) \( \chi = 3 \)
Bipartite Non-Bipartite
Odd cycles? None Contains at least one
Chromatic number \( \chi = 2 \) \( \chi \geq 3 \)
2-colorable? Yes No

The Greedy Coloring Algorithm

The greedy algorithm provides a simple, constructive way to color any graph. It does not always use the fewest colors, but guarantees at most \( \Delta(G) + 1 \).

1
Order the vertices: Choose any ordering \( v_1, v_2, \ldots, v_n \).
2
Process each vertex in order: For \( v_i \), look at the colors already assigned to its neighbors.
3
Assign the smallest available color: Pick the lowest-numbered color not used by any neighbor of \( v_i \).
4
Repeat until all vertices are colored. The result is a proper coloring.

Example: Greedy on a Path Graph

1 2 1 2 1
\( v_1 \)
\( v_2 \)
\( v_3 \)
\( v_4 \)
\( v_5 \)
Only 2 colors needed: \( \chi(P_5) = 2 \)

Example: Coloring \( K_4 \)

1 2 3 4
\( K_4 \): every vertex adjacent to all others

Example: The Wheel Graph \( W_5 \)

1 2 3 2 3
\( W_5 \): hub + 4-cycle rim

The Chromatic Polynomial

The chromatic polynomial \( P(G, k) \) counts the number of proper \( k \)-colorings of \( G \). It is always a polynomial in \( k \).

Complete graph \( K_n \)
\( P(K_n, k) = k(k-1)(k-2)\cdots(k-n+1) \)
Tree on \( n \) vertices
\( P(T, k) = k(k-1)^{n-1} \)
Cycle \( C_n \)
\( P(C_n, k) = (k-1)^n + (-1)^n(k-1) \)

Deletion-Contraction Method

To compute \( P(G, k) \) for any graph, pick any edge \( e = \{u, v\} \) and apply:

1
\( G - e \) (deletion): Remove edge \( e \) but keep both vertices. This "relaxes" the constraint that \( u \) and \( v \) differ.
2
\( G / e \) (contraction): Merge \( u \) and \( v \) into a single vertex, keeping all other edges. This "forces" \( u \) and \( v \) to have the same color.
3
Subtract to correct: colorings where \( u \neq v \) equals (all colorings without the edge constraint) minus (colorings where \( u = v \)).

Common Mistakes

✕ Confusing \( \chi(G) \) with \( \Delta(G) \)
The chromatic number can be much less than the max degree. Brooks' Theorem gives a tighter bound of \( \Delta(G) \) for most graphs.
✕ Greedy = optimal
Greedy coloring depends on vertex ordering. A bad ordering can use more colors than \( \chi(G) \). Only specific orderings guarantee optimality.
✕ Ignoring odd cycles
Students claim a graph is 2-colorable without checking for odd cycles. A single odd cycle forces \( \chi(G) \geq 3 \).

Summary of Key Graphs

Graph Family \( \chi(G) \) Key Property
Complete \( K_n \) \( n \) Every vertex adjacent to all others
Even cycle \( C_{2m} \) \( 2 \) Bipartite: no odd cycles
Odd cycle \( C_{2m+1} \) \( 3 \) Odd cycle forces a third color
Tree / Forest \( 2 \) Bipartite: acyclic connected
Wheel \( W_n \) \( 3 \) or \( 4 \) Hub + cycle rim; depends on rim parity
Planar graph \( \leq 4 \) Four Color Theorem

Question 1 of 5

What is the chromatic number of the complete graph \( K_5 \)?

Question 2 of 5

A graph \( G \) is bipartite. What can you conclude about \( \chi(G) \)?

Question 3 of 5

According to Brooks' Theorem, if \( G \) is a connected graph that is neither a complete graph nor an odd cycle, what is an upper bound on \( \chi(G) \)?

Question 4 of 5

The chromatic polynomial of a tree on \( n \) vertices is \( P(T, k) = \):

Question 5 of 5

In the deletion-contraction formula, \( P(G, k) = P(G - e, k) - P(G/e, k) \). What does \( G/e \) represent?