k-Coloring — Definition, Formula & Examples
A k-coloring of a graph is an assignment of at most distinct colors to the graph's vertices such that no two vertices connected by an edge receive the same color. If a valid k-coloring exists, the graph is called k-colorable.
Given a graph and a positive integer , a proper -coloring is a function such that for every edge . The chromatic number is the smallest for which a proper -coloring of exists.
How It Works
To find a k-coloring, you try to label each vertex with one of colors while ensuring every pair of adjacent vertices gets different colors. Start by picking any vertex and assigning it color 1. Move to an adjacent vertex and assign the lowest-numbered color that does not conflict with its already-colored neighbors. Repeat until all vertices are colored or you discover that colors are insufficient. If you succeed, the graph is -colorable; if not, you need more colors. The minimum that works is the chromatic number .
Worked Example
Problem: Determine whether the cycle graph (a square with vertices and edges forming a cycle) is 2-colorable.
Step 1: Assign color 1 to . Its neighbor must differ, so assign color 2 to .
Step 2: is adjacent to (color 2), so assign color 1 to . Then is adjacent to both (color 1) and (color 1), so assign color 2 to .
Step 3: Check all edges: : , : , : , : . Every edge has differently colored endpoints.
Answer: Yes, is 2-colorable. Its chromatic number is .
Why It Matters
Graph coloring appears directly in scheduling problems (assigning time slots so conflicting events don't overlap), register allocation in compilers, and map coloring. The Four Color Theorem — every planar graph is 4-colorable — is one of the most famous results in mathematics, and understanding k-colorings is the foundation for studying it.
Common Mistakes
Mistake: Confusing k-colorable with requiring exactly k colors.
Correction: A k-coloring uses at most k colors. A graph that is 3-colorable is automatically 4-colorable, 5-colorable, and so on. The chromatic number is the minimum k needed.
