34-3 Graph coloring
Mapmakers try to use as few colors as possible when coloring countries on a map, as long as no two countries that share a border have the same color. We can model this problem with an undirected graph in which each vertex represents a country and vertices whose respective countries share a border are adjacent. Then, a -coloring is a function such that for every edge . In other words, the numbers represent the colors, and adjacent vertices must have different colors. The graph-coloring problem is to determine the minimum number of colors needed to color a given graph.
a. Give an efficient algorithm to determine a -coloring of a graph, if one exists.
b. Cast the graph-coloring problem as a decision problem. Show that your decision problem is solvable in polynomial time if and only if the graph-coloring problem is solvable in polynomial time.
c. Let the language be the set of graphs that can be -colored. Show that if is , then your decision problem from part (b) is .
To prove that is , we use a reduction from . Given a formula of clauses on variables , we construct a graph as follows. The set consists of a vertex for each variable, a vertex for the negation of each variable, vertices for each clause, and special vertices: , , and . The edges of the graph are of two types: "literal" edges that are independent of the clauses and "clause" edges that depend on the clauses. The literal edges form a triangle on the special vertices and also form a triangle on , and for .
d. Argue that in any -coloring of a graph containing the literal edges, exactly one of a variable and its negation is colored and the other is colored . Argue that for any truth assignment for , there exists a -coloring of the graph containing just the literal edges.
The widget shown in Figure 34.20 helps to enforce the condition corresponding to a clause . Each clause requires a unique copy of the vertices that are heavily shaded in the figure; they connect as shown to the literals of the clause and the special vertex .
e. Argue that if each of , , and is colored or , then the widget is -colorable if and only if at least one of , , or is colored .
f. Complete the proof that is .
(Omit!)