7. Colorings
Assign colors to vertices so that no two adjacent vertices share a color. Deciding is NP-Complete ☠️.
Chromatic number : minimum for which a valid -coloring exists.
Examples:
- :
- Even cycle:
- Odd cycle:
- Trees ( nodes): (they’re bipartite)
Bipartite Characterization
Theorem
bipartite contains no odd-length cycle as a subgraph.
Proof idea: Run BFS from any vertex . Color vertex with color if is even, color if odd. No odd cycle no edge connects two same-colored vertices.
Four Color Theorem
Theorem
Every planar map can be colored with four colors.
Proved by Appel & Haken (1977) — the theoretical part reduces the problem to finitely many cases, which are then verified by computer.
Greedy Coloring
Visit vertices in any order . Assign each the smallest color not used by its already-colored neighbors.
Greedy-Coloring(G):
pick any ordering V = {v₁, ..., vₙ}
c[v₁] ← 1
for i = 2 to n:
c[vᵢ] ← min{ k ∈ ℕ | k ≠ c(u) for all u ∈ N(vᵢ) ∩ {v₁,...,vᵢ₋₁} }
Bound:
where is the maximum degree.
Runtime: using an adjacency list (for each , scan its neighbors, mark used colors in a boolean array of size , pick first unused).
Caveat: The number of colors used depends heavily on vertex ordering. There always exists an ordering achieving colors — but we don’t know which one.
example where fails
Saving One Color
Two situations where we can beat and achieve colors in :
Case 1 — Some vertex has : Start BFS/DFS at , number vertices in reverse traversal order (so ). Then every () has at least one neighbor with , leaving at most colored neighbors. The last vertex also has neighbors. Greedy uses colors.
Case 2 — -regular graph with an articulation vertex: Find the articulation vertex (modified DFS, ). Removing splits into components . Each satisfies Case 1, so each is -colorable. Permute colors so gets the same color in all components combined -coloring of .
Brooks’ Theorem
Theorem
If is a connected graph that is neither nor an odd cycle , then: A -coloring can be found in .
Why it’s tight: Complete graphs and odd cycles are the only graph types where .
Proof sketch: By the two cases above, we may assume is -regular with no articulation vertex. Since but is connected, with two non-adjacent neighbors . Then either is connected (use Case 1 style ordering starting from ) or it splits into components (handle like Case 2, carefully managing color swaps).
Note: A star shows the max degree doesn’t always govern : the center can have arbitrarily large degree, yet .
Degeneracy-Based Coloring
Theorem
If every induced subgraph of contains a vertex of degree , then , and a -coloring can be found in .
Algorithm: Repeatedly peel off a vertex of degree (maintaining a queue of low-degree vertices). This gives an ordering where each has neighbors among . Greedy then needs colors.
Runtime: — maintain degree array and a queue of vertices with . Each edge is processed at most twice.
Mycielski Construction — Triangle-Free but High
Theorem
For all , there exists a triangle-free graph with .
Construction (inductive):
- Base: : a single edge.
- Step : Given with vertices :
- Add a “shadow” vertex for each , connected to all neighbors of (but not to itself).
- Add one extra vertex connected to all .
Why it works:
- Still triangle-free: The are not connected to each other, so is in no triangle. Any triangle involving would require a triangle in (which is triangle-free).
- Chromatic number increases: Assume is -colorable. Then some color is absent from ‘s neighborhood. Since and have the same neighbors in , we can recolor to ‘s color wherever needed, producing a -coloring of — contradiction.
Coloring 3-Chromatic Graphs
Given a graph promised to be 3-colorable, we can’t efficiently find the 3-coloring (that’s NP-hard). But we can do better than :
Theorem
Every 3-colorable graph can be colored with colors in time.
Key insight: In a 3-coloring, every vertex’s neighborhood is bipartite (only 2 remaining colors). So can be 2-colored via BFS.
Algorithm:
- While a vertex with : color and its neighborhood with 3 new colors (possible since is bipartite). Remove them.
- Once all remaining degrees : apply Brooks’ theorem colors.
Color count: Step 1 runs times (each round removes vertices), using colors. Step 2 adds . Total: .
State of the art: Coloring with 4 colors is NP-hard, but colors suffices (improving the bound above).