Vertex colorings and chromatic polynomials
Encode conflicts with proper colorings, bound the number of needed colors, and count labeled colorings recursively.
On this page
The question for today
What you’ll understand
- Translate pairwise conflicts into a proper vertex-coloring constraint.
- Prove basic clique and greedy bounds for the chromatic number.
- Use deletion–contraction to count colorings with named colors.
When two tasks cannot share a time slot, put an edge between them. A proper vertex coloring assigns slot labels so adjacent tasks receive different labels. The chromatic number asks for the smallest palette that works, while the chromatic polynomial counts how many assignments work for a given palette. These are related questions, but a feasible coloring alone does not establish minimality.
Color classes are conflict-free groups
For a finite simple graph, a proper -coloring is a function from vertices to named colors with different values at adjacent endpoints. Each color class is an independent set, containing no edge. The chromatic number is the least usable palette size for a nonempty graph. A clique of size forces at least colors because every pair conflicts, but the largest clique does not always determine the answer: an odd cycle needs three colors despite having no triangle.
A greedy coloring examines vertices in a chosen order and gives each the first color absent from its already-colored neighbors. With maximum degree , at most colors are forbidden at any step, proving an upper bound of . A particular order may use fewer colors, but an arbitrary greedy result is not necessarily optimal. To prove the exact chromatic number, pair a lower obstruction, such as a clique or an odd cycle, with an explicit coloring using that many colors.
Count assignments with named colors
Let be the number of proper colorings using colors chosen from a named palette of size ; not every available color must appear. For an edgeless graph on vertices, choices are independent, giving . For a tree on vertices, choose a root color in ways, then each other vertex has choices distinct from its parent. The tree has no extra edges imposing further restrictions, so the product is .
For an edge , count proper colorings of the graph with that edge deleted. They split into those with different colors at u and v, which are exactly the proper colorings of the original graph, and those with equal colors, which correspond to colorings after contracting u and v to one vertex. Rearranging gives deletion–contraction. Parallel edges created by contraction impose duplicate inequality constraints and can be merged for this counting purpose. Repeating the recurrence proves that the count is a polynomial in k.
Cycle parity explains a key obstruction
A graph is bipartite if and only if it has no odd cycle. One direction is immediate: a walk around a cycle alternates the two classes and can return to its starting class only after an even number of steps. Conversely, within each component choose a root and assign classes by even and odd distance from it. An edge joining vertices of the same parity would combine their root paths with that edge to give an odd closed walk, which contains an odd cycle after removing repetitions.
Thus a connected graph with at least one edge is two-colorable exactly when it is bipartite. This characterization is stronger than checking that no triangle occurs: a five-cycle is triangle-free but not bipartite. In scheduling, pairwise conflict graphs also have limits. A constraint saying three tasks cannot all share one slot, while any pair may, is not represented by ordinary edges. Modeling such higher-order restrictions requires different data rather than interpreting a proper graph coloring as a complete schedule certificate.
Work it through
Count a triangle with one attached leaf
A graph has triangle edges and one extra edge . Find its chromatic number and its number of proper colorings from four named colors.
The triangle forces at least three colors. Color a,b,c with three distinct labels, then give d any color other than c. This uses three colors in total if d reuses a's label, proving the chromatic number is three.
For a palette of k named colors, choose a in k ways, b in k−1 ways, and c in k−2 ways because c meets both a and b. Vertex d has k−1 choices because its only neighbor is c.
The product is k(k−1)²(k−2). At k=4 it gives 4×9×2=72. Reusing colors on nonadjacent vertices is permitted, and palette labels are distinguished rather than counted up to permutation.
The chromatic number is three, and there are 72 proper colorings from a four-color named palette.
The living notebook
Explore the model
Interactive lab · modular
Parity around a cycle
Pause and Reset, then set m = 6 and a = 1. As you Step six times, assign alternating colors on paper to newly visited labels and predict whether the closing edge conflicts. Reset and set both m = 5 and a = 1; repeat the alternating assignment and compare the closing edge. Ignore arrow direction to interpret the orbit as an undirected cycle. The instrument does not display or optimize color assignments.
- Residue r0
- 0
- Orbit period · m/gcd(m,a)
- 12
- Distinct residues visited
- 1 of 12
Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forAlternation closes consistently on an even cycle and fails on an odd cycle; labels alone do not determine a general graph's chromatic number.
Pause & reason
Check your understanding
Your turn
Try it yourself
Count proper colorings of the four-cycle from three named colors, and prove its chromatic number. Separate the cases where and have equal or different colors.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
When a and c agree, b and d each avoid one color. When they differ, each of b and d must avoid both colors.
Compare with the solution
If a and c share a color, there are three choices for it and two choices independently for each of b and d, contributing twelve. If a and c differ, choose their ordered colors in three times two ways; b and d are both forced to use the third color, contributing six. The total is eighteen. Alternating one color on {a,c} and another on {b,d} gives a two-coloring, while any edge forbids one color, so the chromatic number is two.
Keep the idea
Take it with you
- A lower obstruction and a matching coloring prove the chromatic number.
- Chromatic polynomials count colorings from a named palette, without requiring every color.
- Bipartite graphs are exactly the graphs with no odd cycle.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.