Combinatorics and discrete mathematics
Graph coloring and the four color theorem
Assigning colors to vertices or regions so neighbors differ; every planar map needs at most four colors.
IntuitionVisual intuition: coloring maps
Imagine coloring the countries on a political map so that any two countries sharing a border always get different colors. This is exactly the graph coloring problem: turn each region into a vertex, and draw an edge between two vertices whenever the two regions are neighbors. A proper coloring assigns a color to every vertex so that the two endpoints of every edge always receive different colors. The smallest number of colors that makes this possible is called the chromatic number, written .
SchoolProper coloring and the chromatic number
Definition: Proper coloring, chromatic number
A proper -coloring of a graph is a function that assigns one of colors to every vertex so that no two adjacent vertices get the same color. The chromatic number is the smallest for which a proper -coloring exists. Equivalently, is the smallest number of independent sets (sets of pairwise non-adjacent vertices) needed to partition all of .
Here ranges over the natural numbers, is the graph being colored, and is the resulting minimum. A useful, easy upper bound comes from the greedy algorithm: order the vertices arbitrarily and color each vertex with the first color not already used by an earlier neighbor. Since every vertex has at most neighbors, this never needs more than + 1 colors, giving .
| Graph family | Chromatic number | Chromatic polynomial |
|---|---|---|
| Complete graph | ||
| Tree on vertices | (if ) | |
| Cycle , odd | ||
| Every planar graph | at most (Four Color Theorem) | no closed form in general |
UndergraduateThe chromatic polynomial
Beyond just the chromatic number, we can count the number of proper -colorings of exactly: this count is a polynomial in , called the chromatic polynomial . It satisfies the deletion-contraction recurrence: pick any edge of , delete it to get , or contract it (merge its two endpoints into one) to get ; then . For the complete graph , every vertex must get a different color, so . For a tree with vertices, the recurrence gives , since the first vertex can take any of colors and each subsequent vertex (attached by one edge) can take any color but its parent's.
UndergraduateKey theorems
Every planar graph satisfies .
Why is it true?
This is a much easier warm-up to the Four Color Theorem: it uses only elementary induction and a clever local swapping trick (a Kempe chain), with no computer assistance, so a reader can verify every step by hand.
Proof
Base case. If has at most 5 vertices, color each vertex a different color; at most 5 colors are used, so the claim holds.
Inductive step, setup. Assume every planar graph with fewer than vertices is 5-colorable, and let be planar with vertices. Every simple planar graph satisfies (edge bound proved via Euler's formula), so the sum of all degrees is at most , which is less than . Hence the average degree is less than 6, so some vertex has degree at most 5.
Remove to get a smaller planar graph with vertices; by the inductive hypothesis it has a proper 5-coloring. If has at most 4 neighbors, at most 4 colors are used among them, leaving a free color for , and we are done.
The remaining case is deg and all 5 colors appear, once each, among the 5 neighbors of . List the neighbors in the cyclic order they appear around in the planar drawing as first, second, third, fourth, fifth, colored 1, 2, 3, 4, 5 respectively. Consider the subgraph formed by all vertices colored 1 or 3. If the first and third neighbors lie in different connected components of , swap colors 1 and 3 throughout the component containing the first neighbor; this stays a proper coloring (it only touches vertices colored 1 or 3), and now the first neighbor is colored 3, so color 1 is free for .
Otherwise the first and third neighbors lie in the same component of , joined by a path alternating colors 1 and 3. Together with and the two edges to the first and third neighbors, this path closes a cycle in the plane that separates the second neighbor from the fourth neighbor (by the Jordan curve theorem, since the cyclic order around is first, second, third, fourth, fifth). Consequently no path of alternating colors 2 and 4 can connect the second and fourth neighbors, since such a path would have to cross the 1-3 cycle. So we swap colors 2 and 4 throughout the component of containing the second neighbor; this frees color 2 for .
In every case receives one of the 5 colors without conflicting with any neighbor, extending the coloring of -v to all of . By induction, for every planar graph.
Every planar graph satisfies .
Why is it true?
This settles the original map-coloring question asked by Francis Guthrie in 1852: four colors always suffice for any planar map, and this bound is tight, since some planar graphs (for example a map with four mutually bordering regions) genuinely require all four colors.
Proof
Reduction to a minimal counterexample. If the theorem were false, take a planar graph requiring 5 or more colors with the fewest possible vertices. Adding edges to a planar graph while keeping it planar can only increase the number of colors needed, so this minimal counterexample can be assumed to be a maximal planar graph (a triangulation), where every face, including the outer one, is bounded by exactly 3 edges.
Discharging setup. Assign to every vertex an initial charge . Using together with and (each face has at least 3 sides), the total charge over all vertices works out to exactly , hence strictly positive. The discharging method then moves charge locally between nearby vertices according to a fixed set of rules, without changing this total; analyzing where positive charge must remain after redistribution shows that some vertex of low degree, together with a specific pattern of neighbors, must occur somewhere in the graph. These finitely many patterns are called the unavoidable configurations, since at least one of them is present in every planar triangulation.
Reducibility. A configuration is called reducible if, whenever it appears inside a hypothetical minimal counterexample, any 4-coloring of the smaller graph obtained by removing or contracting that configuration can always be re-extended to a 4-coloring of the whole graph, contradicting minimality. Appel and Haken (1976) verified computationally that every configuration in their unavoidable list of 1,936 configurations (later trimmed to 633 by Robertson, Sanders, Seymour and Thomas in 1997) is reducible, using well over a thousand hours of computer time. This made the Four Color Theorem the first major theorem whose proof relied essentially on machine computation, later independently re-verified and, in 2005, formally checked line by line inside the Coq proof assistant by Gonthier.
Conclusion. Since every unavoidable configuration is reducible, no minimal counterexample can exist: no planar graph needs 5 or more colors, so for every planar graph .
UndergraduateReal-World Applications and Worked Examples
Graph coloring shows up whenever different tasks must be kept apart because they conflict, but tasks that do not conflict can share a resource. Compilers use it to assign a limited number of CPU registers to program variables (register allocation): two variables that are both "alive" at the same time get an edge, and a valid register assignment is exactly a proper coloring. Universities use it to schedule final exams: two courses sharing a student get an edge, and the minimum number of exam time slots is the chromatic number of that conflict graph. Wireless networks use it to assign radio frequencies to transmitters so that nearby transmitters (which would interfere) never share a frequency.
Example: Register allocation for four temporary variables
A compiler tracks four temporary variables in a loop. Their live ranges overlap as follows: overlaps with and ; overlaps with , and ; overlaps with , and ; overlaps with and only. Build the conflict graph and find the minimum number of CPU registers needed.
Solution
Build the graph. Vertices ; edges (from the overlaps listed), and no edge since and never overlap.
Look for a triangle. Vertices are pairwise adjacent (, , all present), so this graph contains a triangle, meaning at least 3 registers are needed: 2 registers can never properly color a triangle, since any 2-coloring forces two of the three mutually adjacent vertices to share a color.
Try 3 colors (registers) . Set , , (forced distinct since they form a triangle). Now check : is adjacent to (color 2) and (color 3) but not to , so can safely take color 1.
Conclusion. The coloring is proper, so 3 registers suffice, and 3 is also necessary because of the triangle . The minimum number of registers is 3.
Example: Exam scheduling with the fewest time slots
A university offers five courses . Some pairs share at least one enrolled student and so cannot be examined at the same time: pairs , , , , , conflict; all other pairs have no student in common. Find the minimum number of exam time slots needed so that no student has two exams at once.
Solution
Model as a graph. Vertices are the courses; draw an edge for every conflicting pair: . The minimum number of exam slots is exactly of this conflict graph, since two courses can share a slot precisely when they are non-adjacent.
Find a lower bound. Vertices are pairwise adjacent ( all present), so they form a triangle; as in any triangle, 2 colors are not enough, so at least 3 slots are required.
Try 3 slots. Assign course to slot A, course to slot B, course to slot C (forced distinct by the triangle). Course conflicts with (slot B) and (slot C) but not with , so course can go in slot A. Course conflicts only with (slot A), so course can go in slot B (or C).
Conclusion. Slot A , slot B , slot C is a valid schedule with no conflicts, and 3 is optimal because of the triangle . So 3 exam slots are needed and sufficient.
What is the chromatic number of the complete graph on 5 vertices?
A graph has maximum degree . What is the best upper bound on guaranteed by the greedy coloring bound?
In what year did Appel and Haken publish the first proof of the Four Color Theorem, relying on a computer to check thousands of unavoidable configurations?
A university models exam conflicts as a graph : each course is a vertex, and two courses are joined by an edge whenever some student is enrolled in both. What does the minimum possible number of exam time slots equal?
References
- Kenneth Appel, Wolfgang Haken (1977). Every Planar Map Is Four Colorable, Part I: Discharging
- Neil Robertson, Daniel P. Sanders, Paul Seymour, Robin Thomas (1997). The Four-Colour Theorem
- Georges Gonthier (2008). Formal Proof—The Four-Color Theorem
- Reinhard Diestel (2017). Graph Theory