Complexity Theory
68
Complexity Theory
69
k -Colourability
A graph G = (V, E ) is k -colourable, if there is a function : V {1, . . . , k } such that, for each u, v V , if (u, v ) E , (u) = (v )
3-Colourability
3-Colourability is in NP, as we can guess a colouring and verify it. To show NP-completeness, we can construct a reduction from 3SAT to 3-Colourability. which are connected in a For each variable x, have two vertices x, x triangle with the vertex a (common to all variables).
This gives rise to a decision problem for each k . 2-colourability is in P. For all k > 2, k -colourability is NP-complete.
In addition, for each clause containing the literals l1 , l2 and l3 we have a gadget.
Anuj Dawar
May 11, 2007
Anuj Dawar
May 11, 2007
Complexity Theory
70
Complexity Theory
71
Gadget l1
Hamiltonian Graphs
Recall the denition of HAMthe language of Hamiltonian graphs. Given a graph G = (V, E ), a Hamiltonian cycle in G is a path in the graph, starting and ending at the same node, such that every node in V appears on the cycle exactly once.
l2
l3
A graph is called Hamiltonian if it contains a Hamiltonian cycle. The language HAM is the set of encodings of Hamiltonian graphs.
With a further edge from a to b.
Anuj Dawar
May 11, 2007
Anuj Dawar
May 11, 2007
Complexity Theory
72
Complexity Theory
73
Hamiltonian Cycle
We can construct a reduction from 3SAT to HAM Essentially, this involves coding up a Boolean expression as a graph, so that every satisfying truth assignment to the expression corresponds to a Hamiltonian circuit of the graph. This reduction is much more intricate than the one for IND.
Travelling Salesman
Recall the travelling salesman problem Given V a set of nodes. c : V V IN a cost matrix. Find an ordering v1 , . . . , vn of V for which the total cost:
n1
c(vn , v1 ) +
i=1
c(vi , vi+1 )
is the smallest possible.
Anuj Dawar
May 11, 2007
Anuj Dawar
May 11, 2007
Complexity Theory
74
Complexity Theory
75
Travelling Salesman
As with other optimisation problems, we can make a decision problem version of the Travelling Salesman problem. The problem TSP consists of the set of triples (V, c : V V IN, t)
Reduction
There is a simple reduction from HAM to TSP, mapping a graph (V, E ) to the triple (V, c : V V IN, n), where 1 c(u, v ) = 2 and n is the size of V . if (u, v ) E otherwise
such that there is a tour of the set of vertices V , which under the cost matrix c, has cost t or less.
Anuj Dawar
May 11, 2007
Anuj Dawar
May 11, 2007
Complexity Theory
76
Complexity Theory
77
Sets, Numbers and Scheduling
It is not just problems about formulas and graphs that turn out to be NP-complete. Literally hundreds of naturally arising problems have been proved NP-complete, in areas involving network design, scheduling, optimisation, data storage and retrieval, articial intelligence and many others. Such problems arise naturally whenever we have to construct a solution within constraints, and the most eective way appears to be an exhaustive search of an exponential solution space. We now examine three more NP-complete problems, whose signicance lies in that they have been used to prove a large number of other problems NP-complete, through reductions.
3D Matching
The decision problem of 3D Matching is dened as: Given three disjoint sets X , Y and Z , and a set of triples M X Y Z , does M contain a matching? I.e. is there a subset M M , such that each element of X , Y and Z appears in exactly one triple of M ? We can show that 3DM is NP-complete by a reduction from 3SAT.
Anuj Dawar
May 11, 2007
Anuj Dawar
May 11, 2007