Skip to content

Chapter 66. Vertex Coloring

Vertex coloring is the assignment of labels, called colors, to the vertices of a graph. The purpose is usually to separate adjacent vertices. Two vertices joined by an edge represent a conflict: they cannot receive the same color.

This idea turns a graph into a model of incompatibility. If vertices are tasks, an edge may mean that two tasks cannot occur at the same time. If vertices are radio transmitters, an edge may mean that two transmitters interfere. If vertices are exams, an edge may mean that some student must take both exams. A coloring assigns resources so that conflicts are respected.

66.1 Coloring a Graph

Let G=(V,E)G = (V,E) be a graph. A vertex coloring of GG is a function

c:VS, c : V \to S,

where SS is a set of colors.

If S={1,2,,k}S = \{1,2,\ldots,k\}, then cc is called a kk-coloring. The value c(v)c(v) is the color assigned to the vertex vv.

A coloring is proper if adjacent vertices receive different colors. Thus, for every edge uvEuv \in E,

c(u)c(v). c(u) \ne c(v).

This is the main form of coloring studied in elementary graph theory. Unless stated otherwise, a coloring in this chapter means a proper vertex coloring.

66.2 Color Classes

Given a coloring c:VSc : V \to S, each color determines a subset of vertices:

Vi={vV:c(v)=i}. V_i = \{v \in V : c(v) = i\}.

The set ViV_i is called a color class.

In a proper coloring, no two adjacent vertices lie in the same color class. Therefore each color class is an independent set. Conversely, if the vertex set of a graph can be partitioned into kk independent sets, then the graph has a proper kk-coloring.

Thus vertex coloring may be viewed in two equivalent ways.

ViewDescription
Function viewAssign a color to each vertex
Partition viewPartition vertices into independent sets

The partition view is often more useful in proofs. The function view is often more useful in algorithms.

66.3 kk-Colorable Graphs

A graph GG is kk-colorable if it has a proper coloring using at most kk colors.

If GG is kk-colorable, then it is also (k+1)(k+1)-colorable. The extra color may simply remain unused. Therefore colorability is monotone in the number of allowed colors.

The smallest useful values have special names.

Number of colorsMeaning
1The graph has no edges
2The graph is bipartite
3The graph is 3-colorable
4The graph is 4-colorable

A graph is 1-colorable exactly when no edge is present. If an edge uvuv exists, then uu and vv must receive different colors.

A graph is 2-colorable exactly when it is bipartite. The two color classes form the two parts of the bipartition.

66.4 Chromatic Number

The chromatic number of a graph GG, denoted χ(G)\chi(G), is the least number of colors needed in a proper vertex coloring.

χ(G)=min{k:G is k-colorable}. \chi(G) = \min \{k : G \text{ is } k\text{-colorable}\}.

This definition is standard: the chromatic number is the minimum number of colors in a proper coloring.

A coloring using exactly χ(G)\chi(G) colors is called an optimal coloring. A graph with chromatic number kk is called kk-chromatic.

For example:

χ(Kn)=n. \chi(K_n) = n.

In a complete graph KnK_n, every pair of distinct vertices is adjacent. Therefore no two vertices may share a color. All nn vertices require distinct colors.

For a cycle CnC_n,

χ(Cn)={2,n even,3,n odd. \chi(C_n) = \begin{cases} 2, & n \text{ even}, \\ 3, & n \text{ odd}. \end{cases}

An even cycle alternates between two colors. An odd cycle cannot be colored with two colors, because the alternating pattern returns to the starting point with a conflict.

66.5 Examples

Consider the path graph P4P_4:

v1v2v3v4. v_1 - v_2 - v_3 - v_4.

A proper 2-coloring is given by

c(v1)=1,c(v2)=2,c(v3)=1,c(v4)=2. c(v_1)=1,\quad c(v_2)=2,\quad c(v_3)=1,\quad c(v_4)=2.

Thus

χ(P4)=2. \chi(P_4)=2.

Now consider the triangle K3K_3. Each vertex is adjacent to the other two. If one vertex receives color 1 and another receives color 2, the third vertex is adjacent to both, so it requires a third color. Hence

χ(K3)=3. \chi(K_3)=3.

Now consider the square C4C_4. Opposite vertices may share colors, and adjacent vertices differ. Thus

χ(C4)=2. \chi(C_4)=2.

These examples show that the number of vertices alone does not determine the chromatic number. The edge structure determines which vertices may share colors.

66.6 Basic Bounds

Every finite graph GG satisfies

1χ(G)V(G) 1 \le \chi(G) \le |V(G)|

when V(G)V(G) is nonempty.

The upper bound is obtained by assigning a distinct color to every vertex. This is always proper. The lower bound follows because at least one color is required for a nonempty graph.

A better upper bound uses the maximum degree. Let Δ(G)\Delta(G) be the maximum degree of GG. Then

χ(G)Δ(G)+1. \chi(G) \le \Delta(G)+1.

To see this, order the vertices in any way and color them one by one. When a vertex vv is colored, at most Δ(G)\Delta(G) of its neighbors have already received colors. Therefore among Δ(G)+1\Delta(G)+1 available colors, at least one color remains available for vv.

This argument gives a simple greedy coloring proof. It also shows that local degree information gives a global coloring bound.

66.7 Cliques and Lower Bounds

A clique is a set of vertices that are pairwise adjacent. If a graph contains a clique of size rr, then those rr vertices must all receive different colors. Therefore

χ(G)ω(G), \chi(G) \ge \omega(G),

where ω(G)\omega(G) is the clique number of GG, the size of a largest clique.

This lower bound is often useful, but it need not be exact. Some graphs require many colors even when their largest clique is small. Odd cycles of length at least five have clique number 22 but chromatic number 33.

The gap between clique number and chromatic number is one of the central themes of coloring theory.

66.8 Bipartite Graphs as 2-Colorable Graphs

A graph is bipartite if its vertex set can be written as a disjoint union

V=AB V = A \cup B

such that every edge has one endpoint in AA and one endpoint in BB.

This is exactly the same as a proper 2-coloring. Assign color 1 to every vertex in AA, and color 2 to every vertex in BB. Since no edge lies inside AA or inside BB, adjacent vertices receive different colors.

Conversely, if a graph has a proper 2-coloring, the two color classes form a bipartition.

Thus:

G is bipartiteχ(G)2. G \text{ is bipartite} \quad \Longleftrightarrow \quad \chi(G) \le 2.

For a graph with at least one edge,

G is bipartiteχ(G)=2. G \text{ is bipartite} \quad \Longleftrightarrow \quad \chi(G)=2.

66.9 Greedy Coloring

The greedy coloring algorithm colors vertices one at a time. At each step, it assigns the smallest available color that does not conflict with already colored neighbors.

The algorithm depends on the chosen vertex order.

Suppose the vertices are ordered as

v1,v2,,vn. v_1, v_2, \ldots, v_n.

For each viv_i, assign the smallest color not used by any previously colored neighbor of viv_i.

Greedy coloring always produces a proper coloring. However, it may use more colors than necessary. The same graph may receive different numbers of colors under different vertex orders.

This behavior is important. Coloring is partly structural and partly algorithmic. A graph may have a small chromatic number, while a poor coloring order causes a simple algorithm to use more colors.

66.10 Coloring and Scheduling

Vertex coloring gives a clean model for scheduling conflicts.

Let each vertex represent an event. Put an edge between two vertices if the two events cannot occur at the same time. A proper coloring assigns time slots to events so that conflicting events receive different slots.

In this model:

Graph conceptScheduling meaning
VertexEvent
EdgeConflict
ColorTime slot
Proper coloringFeasible schedule
Chromatic numberMinimum number of time slots

For example, in exam scheduling, each exam is a vertex. Two exams are adjacent if some student is enrolled in both. A coloring assigns exam periods. A proper coloring ensures that no student has two exams at the same time.

The chromatic number is the smallest number of periods needed.

66.11 Coloring and Maps

Map coloring is another classical source of graph coloring.

Given a map divided into regions, construct a graph as follows. Each region becomes a vertex. Two vertices are joined by an edge when the corresponding regions share a boundary segment.

A proper vertex coloring of this graph assigns colors to regions so that neighboring regions have different colors.

This converts a geometric problem into a graph problem. The Four Color Theorem states that every planar graph can be colored with at most four colors. In graph-theoretic language, if GG is planar, then

χ(G)4. \chi(G) \le 4.

This theorem is deep. It belongs to planar graph theory, but vertex coloring gives its language.

66.12 Critical Graphs

A graph GG is color-critical, or simply critical, if removing any vertex lowers its chromatic number. More precisely, GG is kk-critical if

χ(G)=k \chi(G)=k

and

χ(Gv)<k \chi(G-v) < k

for every vertex vV(G)v \in V(G).

Critical graphs isolate the obstruction to coloring with fewer colors. For example, KkK_k is kk-critical. Odd cycles are 3-critical.

Critical graphs are useful because many coloring arguments reduce to minimal counterexamples. If a theorem about kk-colorability fails, one can often choose a smallest counterexample. Such a graph usually has critical structure.

66.13 Coloring Subgraphs

If HH is a subgraph of GG, then

χ(H)χ(G). \chi(H) \le \chi(G).

Any proper coloring of GG restricts to a proper coloring of HH. Removing vertices or edges cannot force the use of more colors.

This monotonicity gives immediate lower bounds. If GG contains a subgraph HH whose chromatic number is known, then GG must use at least as many colors as HH.

For example, if GG contains a triangle, then

χ(G)3. \chi(G) \ge 3.

If GG contains K5K_5, then

χ(G)5. \chi(G) \ge 5.

66.14 Common Chromatic Numbers

Several standard graph families have simple chromatic numbers.

GraphChromatic number
Empty graph on nn vertices1, if n>0n>0
Complete graph KnK_nnn
Path PnP_n, n2n \ge 22
Even cycle C2mC_{2m}2
Odd cycle C2m+1C_{2m+1}3
Nonempty bipartite graph2
Tree with at least two vertices2

A tree with at least two vertices is bipartite, hence 2-colorable. Since it has at least one edge, it cannot be 1-colorable. Therefore its chromatic number is 2.

66.15 The Role of Vertex Coloring

Vertex coloring belongs to the structural part of graph theory, but it also has algorithmic and applied significance.

Structurally, coloring measures how far a graph is from being independent or bipartite. It studies the tension between adjacency and grouping.

Algorithmically, coloring asks for efficient methods to assign colors. Some coloring problems are easy, such as testing whether a graph is 2-colorable. Others are computationally difficult; determining chromatic number is generally hard for large graphs, and even planar coloring can involve difficult decision problems.

In applications, coloring converts conflict constraints into a discrete allocation problem. The same formal model appears in scheduling, register allocation, frequency assignment, map coloring, and resource sharing.

66.16 Exercises

  1. Find the chromatic number of P5P_5.

  2. Find the chromatic number of C5C_5.

  3. Prove that every complete graph KnK_n has chromatic number nn.

  4. Prove that every bipartite graph is 2-colorable.

  5. Give an example of a graph with clique number 22 and chromatic number 33.

  6. Apply greedy coloring to C6C_6 using the natural cyclic order of the vertices.

  7. Find an ordering of the vertices of a bipartite graph for which greedy coloring uses more than two colors.

  8. Prove that if HH is a subgraph of GG, then χ(H)χ(G)\chi(H) \le \chi(G).

  9. Construct the conflict graph for four exams where exam pairs (A,B)(A,B), (A,C)(A,C), and (C,D)(C,D) conflict. Find a minimum coloring.

  10. Prove that a graph is 1-colorable if and only if it has no edges.