5.4: Graph Coloring
Let's return now to the subject of Example 1.5 , assigning frequencies to radio stations so that they don't interfere. The first thing that we will need to do is to turn the map of radio stations into a suitable graph, which should be pretty natural at this juncture. We define a graph \(\textbf{G}=(V,E)\) in which \(V\) is the set of radio stations and \(xy \in E\) if and only if radio station \(x\) and radio station \(y\) are within 200 miles of each other. With this as our model, then we need to assign different frequencies to two stations if their corresponding vertices are joined by an edge. This leads us to our next topic, coloring graphs.
When \(\textbf{G}=(V,E)\) is a graph and \(C\) is a set of elements called colors , a proper coloring of \(\textbf{G}\) is a function \(\phi:V \rightarrow C\) such that if \(\phi(x) \neq \phi(y)\) whenever \(xy\) is an edge in \(\textbf{G}\). The least \(t\) for which \(\textbf{G}\) has a proper coloring using a set \(C\) of \(t\) colors is called the chromatic number of \(\textbf{G}\) and is denoted \(\chi(\textbf{G})\). In Figure 5.19 , we show a proper coloring of a graph using 5 colors. Now we can see that our radio frequency assignment problem is the much-studied question of finding the chromatic number of an appropriate graph.
Everyone agrees that the graph \(\textbf{G}\) in Figure 5.19 has chromatic number at most 5. However, there's a bit of debate going on about if \(\chi(\textbf{G})=5\). Bob figures the authors would not have used five colors if they didn't need to. Carlos says he's glad they're having the discussion, since all having a proper coloring does is provide them with an upper bound on \(χ(\textbf{G})\). Bob sees that the graph has a vertex of degree 5 and claims that must mean \(\chi(\textbf{G})=5\). Alice groans and draws a graph with 101 vertices, one of which has degree 100, but with chromatic number 2. Bob is shocked, but agrees with her. Xing wonders if the fact that the graph does not contain a \(K_3\) has any bearing on the chromatic number. Dave's in a hurry to get to the gym, but on his way out the door he says they can get a proper 4-coloring pretty easily, so \(\chi(\textbf{G}) \leq 4\). The rest decide it's time to keep reading.
- What graph did Alice draw that shocked Bob?
- What changed did Dave make to the coloring in Figure 5.19 to get a proper coloring using four colors?
5.4.1 Bipartite Graphs
A graph \(\textbf{G}=(V,E)\) with \(\chi(\textbf{G}) \leq 2\) is called a 2-colorable graph . A couple of minutes of reflection should convince you that for \(n \geq 2\), the cycle \(C_{2n}\) with \(2n\) vertices is 2-colorable. On the other hand, \(C_3≅K_3\) is clearly not 2-colorable. Furthermore, no odd cycle \(C_{2n+1}\) for \(n\geq1\) is 2-colorable. It turns out that the property of containing an odd cycle is the only impediment to being 2-colorable, which means that recognizing 2-colorable graphs is easy, as the following theorem shows.
A graph is 2 -colorable if and only if it does not contain an odd cycle.
- Proof
-
Let \(\textbf{G}=(V,E)\) be a 2-colorable graph whose coloring function partitions \(V\) as \(A \bigcup B\). Since there are no edges between vertices on the same side of the partition, any cycle in \(\textbf{G}\) must alternate vertices between \(A\) and \(B\). In order to complete the cycle, therefore, the number of vertices in the cycle from \(A\) must be the same as the number from \(B\), implying that the cycle has even length.
Now suppose that \(\textbf{G}\) does not contain an odd cycle. Note that we may assume that \(\textbf{G}\) is connected, as each component may be colored individually. The distance \(d(u,v)\) between vertices \(u,v \in V\) is the length of a shortest path from \(u\) to \(v\), and of course \(d(u,u)=0\). Fix a vertex \(v_0 \in V\) and define
\(A = \{v \in V: d(u_0,v)\) is even} and \(B=\{v \in V: d(v_0,v)\) is odd}.
We claim that coloring the vertices of \(A\) with color 1 and the vertices of \(B\) with color 2 is a proper coloring. suppose not. Then without loss of generality, there are vertices \(x,y \in A\) such that \(xy \in E\). Since \(x,y \in A\), \(d(v_0,x)\) and \(d(v_0,y)\) are both even. Let
\(v_0,x_1,x_2,...,x_n = x\)
and
\(v_0,y_1,y_2,...,y_m = y\)
be shortest paths from \(v_0\) to \(x\) and \(y\), respectively. If \(x_1 \neq y_j\) for all \(1 \leq i \leq n\) and \(1 \leq j \leq m\), then since \(m\) and \(n\) are both even,
\(v_0,x_1,x_2,...,x_n = x, y=y_m,y_{m-1},...,y_2,y_1,v_0\)
is an odd cycle in \(\textbf{G}\), which is a contradiction. Thus, there must be \(i,j\) such that \(x_i=y_j\), and we may take \(i,j\) as large as possible. (That is, after \(x_i=y_j\), the two paths do not intersect again.) Thus,
\(x_i,x_{i+1},...,x_n = x, y = y_m, y_{m-1},...,y_j = x_i\)
is a cycle in \(\textbf{G}\). How many vertices are there in this cycle? A quick count shows that it has
\(n-(i-1)+m-(j-1)-1 = n+m - (i+j)+1\)
vertices. We know that n and m are even, and notice that \(i\) and \(j\) are either both even or both odd, since \(x_i=y_j\) and the odd-subscripted vertices of our path belong to \(B\) while those with even subscripts belong to \(A\). Thus, \(i+j\) is even, so \(n+m−(i+j)+1\) is odd, giving a contradiction.
A graph \(\textbf{G}\) is called a bipartite graph when there is a partition of the vertex \(V\) into two sets \(A\) and \(B\) so that the subgraphs induced by \(A\) and \(B\) are independent graphs, i.e., no edge of \(\textbf{G}\) has both of its endpoints in \(A\) or in \(B\). Evidently, bipartite graphs are 2-colorable. On the other hand, when a 2-colorable graph is disconnected, there is more than one way to define a suitable partition of the vertex set into two independent sets.
Bipartite graphs are commonly used as models when there are two distinct types of objects being modeled and connections are only allowed between two objects of different types. For example, on one side, list candidates who attend a career fair and on the other side list the available positions. The edges might naturally correspond to candidate/position pairs which link a person to a responsibility they are capable of handling.
As a second example, a bipartite graph could be used to visualize the languages spoken by a group of students. The vertices on one side would be the students with the languages listed on the other side. We would then have an edge \(xy\) when student \(x\) spoke language \(y\). A concrete example of this graph for our favorite group of students is shown in Figure 5.22 , although Alice isn't so certain there should be an edge connecting Dave and English.
One special class of bipartite graphs that bears mention is the class of complete bipartite graphs . The complete bipartite graph \(K_{m,n}\) has vertex set \(V=V_1 \bigcup V_2\) with \(|V_1|=m\) and \(|V_2|=n\). It has an edge \(xy\) if and only if \(x \in V_1\) and \(y \in V_2\). The complete bipartite graph \(K_{3,3}\) is shown in Figure 5.23 .
5.4.2 Cliques and Chromatic Number
A clique in a graph \(\textbf{G}=(V,E)\) is a set \(K \subset V\) such that the subgraph induced by \(K\) is isomorphic to the complete graph \(K_{|K|}\). Equivalently, we can say that every pair of vertices in \(K\) are adjacent. The maximum clique size or clique number of a graph \(\textbf{G}\), denoted \(ω(\textbf{G})\), is the largest \(t\) for which there exists a clique \(K\) with \(|K|=t\). For example, the graph in Figure 5.14 has clique number 4 while the graph in Figure 5.19 has maximum clique size 2.
For every graph \(\textbf{G}\), it is obvious that \(\chi(\textbf{G})≥ω(\textbf{G})\). On the other hand, the inequality may be far from tight. Before showing how bad it can be, we need to introduce a more general version of the Pigeon Hole Principle . Consider a function \(f:X \rightarrow Y\) with \(|X|=2|Y|+1\). Since \(|X|>|Y|\), the Pigeon Hole Principle as stated in Proposition 4.1 only tells us that there are distinct \(x,x′ \in X\) with \(f(x)=f(x′)\). However, we can say more here. Suppose that each element of \(Y\) has at most two elements of \(X\) mapped to it. Then adding up the number of elements of \(X\) based on how many are mapped to each element of \(Y\) would only allow \(X\) to have (at most) \(2|Y|\) elements. Thus, there must be \(y \in Y\) so that there are three distinct elements \(x,x′,x″ \in X\) with \(f(x)=f(x′)=f(x″)=y\). This argument generalizes to give the following version of the Pigeon Hole Principle:
If \(f:X \rightarrow Y\) is a function and |(|X|≥(m−1)|Y|+1\) , then there exists an element \(y \in Y\) and distinct elements \(x_1,…,x_m \in X\) so that \(f(x_i)=y\) for \(i = 1,...,m\).
We are now prepared to present the following proposition showing that clique number and chromatic number need not be close at all. We give two proofs. The first is the work of J. Kelly and L. Kelly, while the second is due to J. Mycielski.
For every \(t \geq 3\) , there exists a graph \(\textbf{G}_t\) so that \(\chi(\textbf{G}_t)=t\) and \(ω(\textbf{G}_t) = 2\) .
- Proof
-
We proceed by induction on \(t\). For \(t=3\), we take \(G_3\) to be the cycle \(C_5\) on five vertices. Now assume that for some \(t \geq 3\), we have determined the graph \(G_t\). Suppose that \(G_t\) has \(n_t\) vertices. Label the vertices of \(G_t\) as \(x_1,x_2,…,x_{n_t}\). Construct \(G_{t+1}\) as follows. Begin with an independent set \(I\) of cardinality \(t(n_t−1)+1\). For every subset \(S\) of \(I\) with \(|S|=n_t\), label the elements of \(S\) as \(y_1,y_2,…,y_{n_t}\). For this particular \(n_t\)-element subset attach a copy of \(G_t\) with \(y_i\) adjacent to \(x_i\) for \(i=1,2,…,n_t\). Vertices in copies of \(G_t\) for distinct \(n_t\)-element subsets of \(I\) are nonadjacent, and a vertex in \(I\) has at most one neighbor in a particular copy of \(G_t\).
To see that \(ω(G_{t+1})=2\), it will suffice to argue that \(G_{t+1}\) contains no triangle (\(K_3\)). Since \(G_t\) is triangle-free, any triangle in \(G_{t+1}\) must contain a vertex of \(I\). Since none of the vertices of \(I\) are adjacent, any triangle in \(G_{t+1}\) contains only one point of \(I\). Since each vertex of \(I\) is adjacent to at most one vertex of any fixed copy of \(G_t\), if \(y \in I\) is part of a triangle, the other two vertices must come from distinct copies of \(G_t\). However, vertices in different copies of \(G_t\) are not adjacent, so \(ω(G_{t+1})=2\). Notice that \(\chi(G_{t+1}) \geq t\) since \(G_{t+1}\) contains \(G_t\). On the other hand, \(\chi(G_{t+1}) \leq t+1\) since we may use \(t\) colors on the copies of \(G_t\) and a new color on the independent set \(I\). To see that \(\chi(G_{t+1})=t+1\), observe that if we use only \(t\) colors, then by the generalized Pigeon Hole Principle, there is an \(n_t\)-element subset of \(I\) in which all vertices have the same color. Then this color cannot be used in the copy of \(G_t\) which is attached to that \(n_t\)-element subset.
- Proof
-
We again start with \(G_3\) as the cycle \(C_5\). As before we assume that we have constructed for some \(t \geq 3\) a graph \(G_t\) with \(ω(G_t)=2\) and \(\chi(G_t)=t\). Again, label the vertices of \(G_t\) as \(x_1,x_2,…,x_{n_t}\). To construct \(G_{t+1}\), we now start with an independent set \(I\), but now \(I\) has only \(n_t\) points, which we label as \(y_1,y_2,…,y_{n_t}\). We then add a copy of \(G_t\) with \(y_i\) adjacent to \(x_j\) if and only if \(x_i\) is adjacent to \(x_j\). Finally, attach a new vertex \(z\) adjacent to all vertices in \(I\).
Clearly, \(ω(G_{t+1})=2\). Also, \(\chi(G_{t+1}) \geq t\), since it contains \(G_t\) as a subgraph. Furthermore, \(\chi(G_{t+1}) \leq t+1\), since we can color \(G_t\) with colors from \(\{1,2,…,t\}\), use color \(t+1\) on the independent set \(I\), and then assign color 1 to the new vertex \(z\). We claim that in fact \(\chi(G_{t+1} )=t+1\). Suppose not. Then we must have \(\chi(G_{t+1})=t\). Let \(\phi\) be a proper coloring of \(G_{t+1}\). Without loss of generality, \(\phi\) uses the colors in \(\{1,2,…,t\}\) and \(\phi\) assigns color \(t\) to \(z\). Then consider the nonempty set \(S\) of vertices in the copy of \(G_t\) to which \(\phi\) assigns color \(t\). For each \(x_i\) in \(S\), change the color on \(x_i\) so that it matches the color assigned to \(y_i\) by \(\phi\), which cannot be \(t\), as \(z\) is colored \(t\). What results is a proper coloring of the copy of \(G_t\) with only \(t−1\) colors since \(x_i\) and \(y_i\) are adjacent to the same vertices of the copy of \(G_t\). The contradiction shows that \(\chi (G_{t+1}) =t+1\), as claimed.
Since a 3-clique looks like a triangle, Proposition 5.25 is often stated as “There exist triangle-free graphs with large chromatic number.” As an illustration of the construction in the proof of Mycielski, we again refer to Figure 5.19 . The graph shown is \(G_4\). We will return to the topic of graphs with large chromatic number in Section 11.6 where we show that are there graphs with large chromatic number which lack not only cliques of more than two vertices but also cycles of fewer than \(g\) vertices for any value of \(g\). In other words, there is a graph \(\textbf{G}\) with \(\chi(G)=10^6\) but no cycle with fewer than \(10^{10}\) vertices!
5.4.3 Can we Determine Chromatic Number?
Suppose you are given a graph \(\textbf{G}\). It's starting to look like it is not easy to find an algorithm that answers the question “Is \(\chi(G) \leq t\)?” It's easy to verify a certificate (a proper coloring using at most t colors), but how could you even find a proper coloring, not to mention one with the fewest number of colors? Similarly for the question “Is ?\(ω(G) \geq k\)?”, it is easy to verify a certificate. However, finding a maximum clique appears to be a very hard problem. Of course, since the gap between \(\chi(G)\) and \(ω(G)\) can be arbitrarily large, being able to find one value would not (generally) help in finding the value of the other. No polynomial-time algorithm is known for either of these problems, and many believe that no such algorithm exists. In this subsection, we look at one approach to finding chromatic number and see a case where it does work efficiently.
A very naïve algorithmic way to approach graph coloring is the First Fit, or “greedy”, algorithm. For this algorithm, fix an ordering of the vertex set \(V=\{v_1,v_2,…v_n\}\). We define the coloring function \(\phi\) one vertex at a time in increasing order of subscript. We begin with \(\phi(v_1)=1\) and then we define \(\phi(v_{i+1})\) (assuming vertices \(v_1,v_2,…,v_i\) have been colored) to be the least positive integer color that has not already been used on any of its neighbors in the set \(\{v_1,...v_i\}\).
Figure 5.26 shows two different orderings of the same graph. Exercise 5.9.24 demonstrates that the ordering of \(V\) is vital to the ability of the First Fit algorithm to color \(\textbf{G}\) using \(\chi(G)\) colors. In general, finding an optimal ordering is just as difficult as coloring \(\textbf{G}\). Thus, this very simple algorithm does not work well in general. However, for some classes of graphs, there is a “natural” ordering that leads to optimal performance of First Fit. Here is one such example—one that we will study again in the next chapter in a different context.
Given an indexed family of sets \(\mathcal{F}=\{S_{\alpha}:\alpha \in V\}\), we associate with \(\mathcal{F}\) a graph \(\textbf{G}\) defined as follows. The vertex set of \(\textbf{G}\) is the set \(V\) and vertices \(x\) and \(y\) in \(V\) are adjacent in \(\textbf{G}\) if and only if \(S_x \cap S_y \neq \emptyset\). We call \(\textbf{G}\) an intersection graph . It is easy to see that every graph is an intersection graph ( Why? ), so it makes sense to restrict the sets which belong to \(\mathcal{F}\). For example, we call \(\textbf{G}\) an interval graph if it is the intersection graph of a family of closed intervals of the real line \(\mathbb{R}\). For example, in Figure 5.27 , we show a collection of six intervals of the real line on the left. On the right, we show the corresponding interval graph having an edge between vertices \(x\) and \(y\) if and only if intervals \(x\) and \(y\) overlap.
If \(G=(V,E)\) is an interval graph, then \(\chi(G) = ω(G)\) .
- Proof
-
For each \(v \in V\), let \(I(v)=[a_v,b_v]\) be a closed interval of the real line so that \(uv\) is an edge in \(\textbf{G}\) if and only if \(I(u) \cap I(v) \neq \emptyset\). Order the vertex set \(V\) as \(\{v_1,v_2,…v_n\}\) such that \(a_1 \leq a_2 \leq \cdot \cdot \cdot \leq a_n\). (Ties may be broken arbitrarily.) Apply the First Fit coloring algorithm to \(\textbf{G}\) with this ordering on \(V\). Now when the First Fit coloring algorithm colors \(v_i\), all of its neighbors have left end point at most \(a_i\). Since they are neighbors of \(v_i\), however, we know that their right endpoints are all at least \(a_i\). Thus, \(v_i\) and its previously-colored neighbors form a clique. Hence, \(v_i\) is adjacent to at most \(ω(G)−1\) other vertices that have already been colored, so when the algorithm colors \(v_i\), there will be a color from \(\{1,2,…,ω(G)\}\) not already in use on its neighbors. The algorithm will assign \(v_i\) the smallest such color. Thus, we never need to use more than \(ω(G)\) colors, so \(\chi(G) = ω(G)\).
A graph \(\textbf{G}\) is said to be perfect if \(\chi(H)=ω(H)\) for every induced subgraph \(H\). Since an induced subgraph of an interval graph is an interval graph, Theorem 5.28 shows interval graphs are perfect. The study of perfect graphs originated in connection with the theory of communications networks and has proved to be a major area of research in graph theory for many years now.