- 85 Views
- Uploaded on
- Presentation posted in: General

NP-Completeness

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

NP-Completeness

More Reductions

- P:is the class of all decision problems which can be solved in polynomial time, O(n^k) for some constant k.
- For example MST ∈Pbut HC is not known (and suspected not) to be in P.
- Certificate: is a piece of evidence that allows us to verify in polynomial time that a string is in a given language. (i.e. Verify an input string is a solution or not)
- For example, suppose that the language is the set of Hamiltonian graphs. To convince someone that a graphis in this language, we could supply the certificate consisting of a sequence of vertices along the cycle. It iseasy to access the adjacency matrix to determine that this is a legitimate cycle in G. Therefore HC ∈NP.

- NP: This is the set of all decision problems that can be verified in polynomial time
- This class contains P as a subset. Thus, it contains a number of easy problems
- It alsocontains a number of problems that are believed to be very hard to solve.
- Originally the term meant “nondeterministic polynomial time”.
- Inrealterms, theperspective of verification is important

NP-hard does not mean that it is hard to solve

- it means that if we could solve this problem in polynomial time, then we could solve all NP problems inpolynomial time.
- for a problem to be NP-hard, it does not have to be in the class NP
- Since itis widely believed that all NP problems are not solvable in polynomial time, it is widely believed that noNP-hard problem is solvable in polynomial time.

- A problem is NP-complete if (1) it is in NP, and (2) it is NP-hard. That is, NPC = NPcrossNP-hard.

- NPis the class of algorithms that can be verified by a polynomial time algorithm
- The original term NP stood for “nondeterministic polynomialtime”. This referred to a program running on a nondeterministic computerthat can make guesses.
- Basically,such a computer could nondeterministically guess the value of certificate, and then verify that the string is inthe language in polynomial time.
- Observethat P \subset NP. In other words, if we can solve a problem in polynomial time, then we can certainly verifymembership in polynomial time. (More formally, we do not even need to see a certificate to solve the problem,we can solve it in polynomial time anyway).

- It seems unreasonable to think that this should be so. In other words,just being able to verify that you have a correct solution does not help you in finding the actual solution very
much.

- Most experts believe that P \neq NP, but no one has a proof of this..

- Hamiltonian cycle problem.: Given an undirected graph G, does G have a cycle that visits every vertex exactly once
The first graph is Non-Hamiltonian, second is Hamiltonian

No known algorithm to solve Hamiltonian Cycle Problem (HC)

We can however check whether a given cycle is Hamiltonian

- The class of NP-complete problems consists of a set of decision problems (a subset of theclass NP) that no one knows how to solve efficiently, but if there were a polynomial time solution for even asingle NP-complete problem, then every problem in NP would be solvable in polynomial time.
- Reductions : Suppose that there are two problems,We know (or you strongly believe at least) that H is hard, that is it cannot be solved in polynomialtime.H and U.
- The complexity of U is unknown, but we suspect that it too is hard. To provethat U cannot be solved in polynomial time. Show :
- (H P) (U }} P):
- To do this, we could prove the contrapositive,
- (U P)) (H P):

- In other words, to show that U is not solvable in polynomial time, we will suppose that there is an algorithm thatsolves U in polynomial time, and then derive a contradiction by showing that H can be solved in polynomial time.
- How do we do this? Suppose that we have a subroutine that can solve any instance of problem U in polynomialtime. Then we need to show we can use this subroutine to solve problem H in polynomial time.
- Thus we have “reduced” problem H to problem U. It is important to note here that this supposed subroutineis really a fantasy.
- We know (or strongly believe) that H cannot be solved in polynomial time, thus we areessentially proving that the subroutine cannot exist, implying that U cannot be solved in polynomial time.

- 3-coloring (3Col): Given a graph G, can each of its vertices be labeled with one of 3 different “colors”, suchthat no two adjacent vertices have the same label
- Planar graphs can be colored with 4 colors, and there exists a polynomial time algorithm for this
- But, determining whether 3 colors are possible (even for planar graphs) seems to be hard and there is no known polynomial time algorithm

- Clique Cover (CCov): Given a graph G =(V,E)and an integer k, can we partition the vertex set into k subsets of vertices V1,V2,...,Vk, such that Ui Vi =V , and that each Vi is a clique of G. (used in clustering)
- Example of two graphs that are 3-colorable, not 3-colorable and a Clique Cover (size=3) are above.

- The 3Col problem will play the role of the hard problem H, which we strongly suspect to not be solvable in polynomial time. The unknown problem U is the Clique Cover
- To solve the CCov problem, after many tries, we want to prove that there’s no poly-time solutions
- We know 3-Col is NP-Complete so 3Col P
- Show :
- (3Col P) (CCov P);which can be shown by :
- (CCov P) (3Col P):

- To do this, you assume that you have access to a subroutine CCov(G, k).Given a graph G and an integer k, thissubroutine returns true if G has a clique cover of size k and false otherwise and
- This subroutineruns in polynomial time
- We want to write a polynomial time subroutine for 3Col, and this subroutine is allowed to call the subroutineCCov(G, k) for any graph G and any integer k.
- Both problems involve partitioning the vertices up into groups. The only difference here is that in one problemthe number of cliques is specified as part of the input and in the other the number of color classes is fixed at 3.

- In the clique cover problem, for two vertices to be in the same group they must be adjacent to each other.
- In the3-coloring problem, for two vertices to be in the same color group, they must not be adjacent.
- In some sense,the problems are almost the same, but the requirement adjacent/non-adjacent is exactly reversed.

- Given a graph for which we want to determine its 3-colorability, output the pair (~G, 3) where ~G denotes the complement of G.
- Feed (~G,3) into a subroutine for clique cover

- Claim: A graph G is 3-colorable if and only if its complement G has a clique-cover of size 3 :
- G 3Col iff (~G, 3) CCov:
- Proof: If G 3-colorable, then let V1; V2; V3 be the three color classes. We claim that this is a clique coverof size 3 for ~G, since if u and v are distinct vertices in Vi, then {u,v} E(G) (since adjacent verticescannot have the same color) which implies that {u,v} E(~G). Thus every pair of distinct vertices in Viare adjacent in ~G.
- Suppose ~G has a clique cover of size 3, denoted V1; V2; V3. For i {1,2,3} give the vertices of Vicolor i. We assert that this is a legal coloring for G, since if distinct vertices u and v are both in Vi, then {u,v} E(G) (since they are in a common clique), implying that {u,v} E(~G). Hence, two verticeswith the same color are not adjacent.

- Given an undirected graph G =(V,E) and an integer k, does G contain a subset V of k vertices such that no two vertices in V are adjacent to one another.
- The independent set problem arises when there is some sort of selection problem, but there are mutual restrictions pairs that cannot both be selected (Don’t invite two people to party who cannot get on)

- Challenge : ﬁnd an independent set of the largest size in a graph.
- Vertices may have weights,then the problem becomes computing the independent set with the largest total weight.
- Claim: IS is NP-Complete
- First part (Certificate ) : The certificate consists of the k vertices ofV ‘. We simply verify that for each pair of vertex u, v in V’ , there is no edge between them. This can bedone in polynomial time, by an inspection of the adjacency matrix.
- Second Part : Show that IS is NP-hard by reducing an NP-Complete Problem to it. We’ve already done it (3SAT <=IS)

- Clique (CLIQUE): The cliqueproblem is: given an undirected graph G =(V,E)and an integer k, does G have a subset V’of k vertices such that for each distinct u,v ∈V‘, {u,v}∈E. In other words, does G have a k vertex subset whose induced subgraph is complete.
- A vertex cover in an undirected graph G =(V,E)is a subset of vertices V’∈V such that every edge in G has at least one endpoint in V’. The vertex cover problem(VC) is: given an undirected graph G and an integer k, does G have a vertex cover of size k?

- Dominating Set (DS): A dominating set in a graph G =(V,E)is a subset of vertices V’such that every vertex in the graph is either in V’or is adjacent to some vertex in V’. The dominating set problem (DS) is: given a graph G =(V, E)and an integer k, does G have a dominating set of size k?
- The clique problem seeks to find a single clique of size k, and the clique-cover problem seeks to partitionthe vertices into k groups, each of which is a clique (different) .

- Cliques are of interest in applications dealing with clustering.
- The vertex cover problem arises in various servicing applications. For example, you have a compute network and a program that checks the integrity of the communication links. To save the space of installing the program on every computer in the network, it sufﬁces to install it on all the computers forming a vertex cover. From these nodes all the links can be tested.
- Dominating set is useful in facility location problems. For example, suppose we want to select where to place a set of ﬁre stations such that every house in the city is within 2 minutes of the nearesﬁre station

- The CLIQUE problem is obviously closely related to the independent set problem (IS): Given a graph G does it have a k vertex subset that is completely disconnected. It is not quite as clear that the vertex cover problem is related. However, the following lemma makes this connection clear as well.
- Lemma: Given an undirected graph G = (V;E) with n vertices and a subset V’\subset V of size k. The followingare equivalent:
(i) V ‘ is a clique of size k for the complement, G’

(ii) V’ is an independent set of size k for G

(iii) V − V ‘ is a vertex cover of size n − k for G

- a) V’ is CLIQUE of size k in G’ iff
- b) V’ is an IS ofsize k in G iff
- c) V−V’ is a VC of size n−k in G

- Proof:
- (i)(ii): If V’ is a clique for G’, then for each u,v ∈ V’, {u,v} is an edge of G’ implying that {u,v} isnot an edge of G, implying that V’ is an independent set for G.
- (ii) (iii): If V’ is an independent set for G, then for each u,v∈ V’, {u,v} is not an edge of G, implyingthat every edge in G is incident to a vertex in V − V’, implying V − V’ is a VC forG.
- (iii) (i): If V −V’ is a vertex cover for G, then for any u,v ∈ V’ there is no edge {u,v} in G, implyingthat there is an edge {u,v} in G’, implying that V’ is a clique in G’. V’ is anindependent set for G.

Theorem: CLIQUE is NP-complete.

1. CLIQUE ∈NP: The certificate consists of the k vertices in the clique. Given such a certificate we can easilyverify in polynomial time that all pairs of vertices in the set are adjacent.

2. IS <= CLIQUE: We want to show that given an instance of the IS problem (G,k), we can produce an equivalentinstance of the CLIQUE problem in polynomial time. The reduction function f inputs G and k, andoutputs the pair (G’, k). Clearly this can be done in polynomial time. By the above lemma, this instance isequivalent.

- Theorem: VC is NP-complete
1. VC ∈ NP: The certificate consists of the k vertices in the vertex cover. Given such a certificate we can easilyverify in polynomial time that every edge is incident to one of these vertices.

2. IS <= VC: We want to show that given an instance of the IS problem (G, k), we can produce an equivalentinstance of the VC problem in polynomial time. The reduction function f inputs G and k, computes thenumber of vertices, n, and then outputs (G, n − k).Clearly this can be done in polynomial time. By thelemma above, these instances are equivalent.

- As with vertex cover, dominating set is an example of a graph covering problem. Each vertex is adjacent to the members of the dominating set, as opposed to each edge beingincident to each member of the dominating set.
- If G is connected and has a vertex cover of size k,then it has a dominating set of size k (the same set of vertices), but the converse is not necessarily true.
- If VC in NP-complete, then DS is likely to be NP-complete as well.

- We can use a reduction from CLIQUE
- Any graph G has a complement G with the same vertices, but with exactly the opposite set of edges
- (u, v) is an edge in G if and only if it is not an edge in G.
- Aset of vertices forms a clique in G if and only if the same vertices are an independent set in G.
- Thus, we can compute the largest clique in a graph simply by computing the largest independent set in the complement of the graph.

- Need a reduction algorithm that transforms a 3CNF formulainto a graph that has a clique of a certain size if and only if the formula is satisfiable.
- The graphhas one node for each instance of each literal in the formula. Two nodes are connected by an edgeif (1) they correspond to literals in different clauses and (2) those literals do not contradict eachother. In particular, all the nodes that come from the same literal (in different clauses) are joinedby edges.

- (a v b v c) ^ (b v c’v d’) ^ (a’v c v d) ^ (a v b’v d’)
is transformed to :

- Now suppose the original formula had k clauses. Then the formula is satisfiable ifand only if the graph has a clique of size k.
- k-clique satisfying assignment: If the graph has a clique of k vertices, then eachvertex must come from a different clause. To get the satisfying assignment, we declare thateach literal in the clique is true. Since we only connect non-contradictory literals with edges,this declaration assigns a consistent value to several of the variables. There may be variablesthat have no literal in the clique; we can set these to any value we like.
2. satisfying assignment k-clique: If we have a satisfyingassignment, then we canchoose one literal in each clause that is true. Those literals form a clique in the graph.

- Since the reduction from 3CNF formula to graph takes polynomialtime, we conclude that MAXCLIQUE is NP-hard.
O(n)

Graph with k nodes

3CNF with k clauses

TRUE or FALSE

Max. Clique size

- Anygraph G has a complement G’ with the same vertices, but with exactly the opposite set of edges(u, v) is an edge in G’ if and only if it is not an edge in G. A set of vertices forms a clique in G if andonly if the same vertices are an independent set in G’.
- Thus, we can compute the largest clique in agraph simply by computing the largest independent set in the complement of the graph. GG’ is O(n)

G’=(V,E’)

G=(V,E)

Largest Clique

Largest IS

- TheVertex Cover problem is to find the smallest vertex cover in a given graph (once more).
- If I is an independent setin a graph G = (V,E), then V \ I is a vertex cover. Thus, to find the largest independent set, wejust need to find the vertices that aren’t in the smallest vertex cover of the same graph. VC to IS is O(n)

G(V,E)

G=(V,E)

Smallest VC S

Largest IS V \ S

- PLANARCIRCUITSAT: Given a boolean circuit that can be embedded in the plane so that notwo wires cross, is there an input that makes the circuit output TRUE? This can be provedby reduction from the general circuit satisfiability problem, by replacing each crossingwith a small series of gates.
- NOTALLEQUAL3SAT: Given a 3CNF formula, is there an assignment of values to the variablesso that every clause contains at least one true literal and at least one false literal? This can beprovedby reduction from the usual 3SAT.
- HITTINGSET: Given a collection of sets S = {S1, S2, . . . , Sm}, find the minimum number ofelements of Ui Si that hit every set in S. This is also a generalization ofVERTEXCOVER.

- LONGESTPATH: Given a non-negatively weighted graph G and two vertices u and v, what isthe longest simple path from u to v in the graph? A path is simple if it visits each vertexat most once. This is a generalization of the HAMILTONIANPATH problem. Of course, thecorresponding shortest path problem is in P.
- STEINERTREE:Given a weighted, undirected graph G with some of the vertices marked, whatis the minimum-weight subtree of G that contains every marked vertex? If every vertex ismarked, the minimum Steiner tree is just the minimum spanning tree; if exactly two verticesare marked, the minimum Steiner tree is just the shortest path between them. This can beprovedby reduction to HAMILTONIANPATH.