• No results found

NP-complete problems for graphs

In document Complexity of Algorithms (Page 115-121)

6.6 Further NP-complete problems

6.6.1 NP-complete problems for graphs

One might think that NP-complete problems are of logical character. In what follows, we will show the NP-completeness of a number of important “everyday” combinatorial, algebraic, etc. problems. When we show about a problem that it is NP-complete, then it follows that it is not in P unless P = NP. Therefore we can consider the NP-completeness of a language as a proof of its undecidability in polynomial time.

Let us formulate a fundamental combinatorial problem:

Problem 6.6.1 Blocking Set Problem: Given a system {A1, . . . , Am} of finite sets and a

We have met a special case of this problem, the Blocking Set Problem for the edges of a bipartite graph. This special case was polynomial time solvable. In contrast to this, we prove:

Theorem 6.6.1 The Blocking Set Problem is NP-complete.

Proof. We reduce 3-SAT to this problem. For a given conjunctive 3-normal form B we construct a system of sets as follows: let the underlying set be the set{x1, . . . , xn, x1, . . . , xn}

of the variable symbols occurring inB and their negations. For each clause ofB, let us take the set of literals occurring in it; let us further take the sets{xi, xi}. The elements of this

set system can be blocked with at mostnnodes if and only if the normal form is satisfiable. ¤

The Blocking Set Problem remains NP-complete even if we impose various restrictions on the set system. It can be seen from the above construction that the Blocking Set Problem is NP-complete even for a system of sets with at most three elements. (We will see a little later that this holds even if the system contains only two-element sets, i.e., the edges of a graph.) If we reduce the language SAT first to the language SAT-3 according to Theorem 6.5.8 and apply to this the above construction then we obtain a set system for which each element of the underlying set is in at most 4 sets.

With a little care, we can show that the Blocking Set Problem remains NP-complete even for set-systems in which each element is contained in at most 3 sets. Indeed, it is easy to reduce the Satisfiablity Problem to the case when the input is a conjunctive normal form in which every variable occurs at least once negated and at least one unnegated; then the construction above gives such a set-system.

We cannot go further than this: if each element is in at most 2 sets then the Blocking Set Problem is solvable in polynomial time. In fact, it is easy to reduce this special case of the blocking set problem to the matching problem.

It is easy to see that the following problem is equivalent to the Blocking Set Problem (only the roles of “elements” and “subsets” must be interchanged):

Problem 6.6.2 Covering problem: Given a system{A1, . . . , Am}of subsets of a finite setS

and a natural numberk. Cank sets be selected in such a way that their union is the whole setS?

According to the discussion above, this problem is NP-complete already even when each of the given subsets has at most 3 elements. has only 2 elements, the problem becomes polynomially solvable, as the following exercise shows:

6.6. FURTHERNP-COMPLETE PROBLEMS 111 Exercise 6.6.1 Prove that the covering problem, if every set in the set system is restricted to have at most 2 elements, is reducible to the following matching problem: given a graphG

and a natural number k, is there a matching of sizekin G?

For set systems, the following pair of problems is also important:

Problem 6.6.3 k-partition problem: Given a system{A1, . . . , Am}of subsets of a finite set

V and a natural numberk. Can a subsystem ofksets{Ai1, . . . , Aik}be selected that gives a

partitionof the underlying set (i.e. consists of disjoint sets whose union is the whole setV)? Problem 6.6.4 Partition problem: Given a system{A1, . . . , Am} of subsets of a finite set

S. Can a subsystem (of any size) be selected that gives a partition of the underlying set? If all the Ai are of the same size, then of course the number of sets in a partition is

uniquely determined, and so the two problems are equivalent.

Theorem 6.6.2 The k-partition problem and the partition problem areNP-complete. Proof. We reduce the the Covering Problem with sets having at most 3 elements to the

k-partition problem. Thus we are given a system of sets with at most 3 elements and a natural numberk. We want to decide whetherkof these given sets can be selected in such a way that their union is the whole S. Let us expand the system by adding all subsets of the given sets (it is here that we exploit the fact that the given sets are bounded: from this, the number of sets grows as most 23 = 9-fold). Obviously, ifksets of the original system cover

S thenk appropriate sets of the expanded system provide a partition ofS, and vice versa. In this way, we have found that thek-partition problem is NP-complete.

Second, we reduce thek-partition problem to the partition problem. LetU be ak-element set disjoint from S. Let our new underlying set be S∪U, and let the sets of our new set system be the sets of form Ai∪ {u} where u∈ U. Obviously, if from this new set system,

some sets can be selected that form a partition of the underlying set then the number of these is k and the parts falling inS give a partition of S into k sets. Conversely, every partition of S into ksets Ai provides a partition of the setS∪U into sets from the new set system.

Thus, the partition problem is NP-complete. ¤

If the given sets have two elements then the Set Partition Problem is just the perfect matching problem and can therefore be solved in polynomial time. The argument above shows that, on the other hand, the Set Partition Problem for sets with at most 3 elements is NP-complete.

x1

x

x

x

x

x

x

x

2

2

3

3

4

4

1

u

v

Figure 6.3: The graph whose 3-coloring is equivalent to satisfying the expression (x1∨x2∨x4)(x1∨x2∨x3)

Next we treat a fundamental graph-theoretic problem, the coloring problem. We have seen that the problem of coloring with two colors is solvable in polynomial time. On the other hand:

Theorem 6.6.3 The coloring of graphs with three colors is anNP-complete problem. Proof. Let us be given a 3-form B; we construct a graphG for it that is colorable with three colors if and only ifB is satisfiable.

For the nodes of the graphG, we first take the literals, and we connect each variable with its negation. We take two more nodes,uandv, and connect them with each other, further we connectuwith all unnegated and negated variables. Finally, we take a pentagon for each elementary disjunction zi1∨zi2∨zi3; we connect two neighboring vertices of the pentagon

with v, and its three other vertices with zi1, zi2 and zi3. We claim that the graph G thus

constructed is colorable with three colors if and only ifB is satisfiable (Figure 6.3).

The following remark, which is very easily verified, plays a key role in the proof: if for some clausezi1∨zi2∨zi3, the nodeszi1,zi2,zi3 andv are colored with three colors then this

coloring can be extended to the pentagon as a legal coloring if and only if the colors of zi1,

6.6. FURTHERNP-COMPLETE PROBLEMS 113 Let us first assume that B is satisfiable, and let us consider the corresponding value assignment. Let us color red those (negated or unnegated) variables that are “true”, and blue the others. Let us coloruyellow andv blue. Since every elementary disjunction must contain a red node, this coloring can be legally extended to the nodes of the pentagons.

Conversely, let us assume that the graph G is colorable with three colors and let us consider a “legal” coloring with red, yellow and blue. We can assume that the nodevis blue and the node u is yellow. Then the nodes corresponding to the variables can only be blue and red, and between each variable and its negation, one is red and the other one is blue. Then the fact that the pentagons are also colored implies that each elementary disjunction contains a red node. But this also means that taking the red nodes as “true”, we get a value

assignment satisfyingB. ¤

It follows easily from the previous theorem that for every numberk≥3 thek-colorability of graphs is NP-complete.

The following is another very basic graph theory problem. A setSof nodes of a graph is independent, if no edge connects two of them.

Problem 6.6.5 Independent node set problem: Given a graphGand a natural number k, are therek independent nodes inG?

Theorem 6.6.4 The independent node set problem is NP-complete.

Proof. We reduce to this problem the problem of coloring with 3 colors. Let G be an arbitrary graph with n nodes and let us construct the graph H as follows: Take three disjoint copiesG1,G2,G3ofGand connect the corresponding nodes of the three copies. Let

H be the graph obtained, this has thus 3nnodes.

We claim that there are n independent nodes in H if and only if G is colorable with three colors. Indeed, if Gis colorable with three colors, say, with red, blue and yellow, then the nodes inG1 corresponding to the red nodes, the nodes inG2 corresponding to the blue

nodes and the nodes in G3 corresponding to the yellow nodes are independent even if taken

together in H, and their number is n. The converse can be proved similarly. ¤ In the set system constructed in the proof of Theorem 6.6.1 there were sets of at most three elements, for the reason that we reduced the 3-SAT problem to the Blocking Set Problem. Since the 2-SAT problem is in P, we could expect that the Blocking Set Problem for two-element sets is in P. We note that this case is especially interesting since the issue here is the blocking of the edges of graphs. We can notice that the nodes outside a blocking set are independent (there is no edge among them). The converse is true in the following sense: if an independent set is maximal (no other node can be added to it while preserving

independence) then its complement is a blocking set for the edges. Our search for a minimum Blocking set can therefore be replaced with a search for a maximum independent set, which is also a fundamental graph-theoretical problem. Formulating it as a yes-no question: Remark 6.6.1 The independent vertex set problem (and similarly, the Blocking set prob- lem) are only NP-complete if k is part of the input. It is namely obvious that if we fix k

(e.g.,k= 137) then for a graph ofnnodes it can be decided in polynomial time (in the given example, in time O(n137)) whether it has k independent nodes. The situation is different

with colorability, where already the colorability with 3 colors is NP-complete.

From the NP-completeness of the Independent Set Problem, we get the NP-completeness of two other basic graph-theory problems for free. First, notice that the complement of an independent set of nodes is a blocking set for the family of edges, and vice versa. Hence we get

Corollary 6.6.5 The Blocking Set Problem for the family of edges of a graph is NP-complete.

(Recall that in the special case when the graph is bipartite, then the minimum size of a blocking set is equal to the size of a maximum matching, and therefore it can be computed in polynomial time.)

Another easy transformation is to look at the complementary graph Gof G(this is the graph on the same set of nodes, with “adjacent” and “non-adjacent” interchanged). An independent set inGcorresponds to a clique (complete subgraph) inGand vice versa. Thus the problem of finding a k-element independent set is (trivially) reduced to the problem of finding ak-element clique.

Corollary 6.6.6 The problem of deciding whether a graph has a clique of size k is NP- complete.

Very many other important combinatorial and graph-theoretical problems are NP- complete:

Does a given graph have a Hamiltonial circuit?

Can we cover the nodes with disjoint triangles (for “2-angles”, this is the matching problem!),

Does there exist a family ofknode-disjoint paths connectingkgiven pairs of nodes? The book “Computers and Intractability” by Garey and Johnson(Freeman, 1979) lists NP-complete problems by the hundreds.

6.6. FURTHERNP-COMPLETE PROBLEMS 115

In document Complexity of Algorithms (Page 115-121)