Np completeness
This presentation is the property of its rightful owner.
Sponsored Links
1 / 37

NP-Completeness PowerPoint PPT Presentation


  • 81 Views
  • Uploaded on
  • Presentation posted in: General

NP-Completeness. More Reductions. Definitions. 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 ∈ P but HC is not known (and suspected not) to be in P.

Download Presentation

NP-Completeness

An Image/Link below is provided (as is) to download presentation

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 - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Np completeness

NP-Completeness

More Reductions


Definitions

Definitions

  • 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 completeness

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

NP-Hard

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.


Np completeness1

NP Completeness

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


The class np

The Class NP

  • 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).


Np completeness

P=NP ??

  • 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

Hamiltonian Cycle

  • 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


Reductions

Reductions

  • 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):


Reductions1

Reductions

  • 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.


Ex 3 colorability and clique cover

Ex: 3-Colorability and Clique Cover

  • 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


Covers

Covers

  • 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.


Covers1

Covers

  • 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):


Covers and reductions

Covers and Reductions

  • 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.


Cover reductions

Cover Reductions

  • 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.


Reduction of 3 col problem to ccov

Reduction of 3-Col problem to CCov

  • 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


Proof

Proof

  • 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.


Independent set is problem

Independent Set (IS) Problem

  • 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)


Independent set problem

Independent Set Problem

  • Challenge : find 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)


Definitions1

Definitions

  • 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?


Definitions2

Definitions

  • 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) .


Applications

Applications

  • 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 suffices 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 fire stations such that every house in the city is within 2 minutes of the nearesfire station


Clique is and vc

Clique, IS and VC

  • 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


Equivalences

Equivalences

  • 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 of lemma

Proof of Lemma

  • 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.


Clique is np complete

CLIQUE is NP-complete

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.


Vc is np complete

VC is NP-complete

  • 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.


Dominatingset

DominatingSet

  • 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.


More reductions is from clique

More Reductions : IS from CLIQUE

  • 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.


Clique from 3 sat

CLIQUE from 3-SAT

  • 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.


Example

Example

  • (a v b v c) ^ (b v c’v d’) ^ (a’v c v d) ^ (a v b’v d’)

    is transformed to :


Example1

Example

  • 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.


Method

Method

  • 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


Independent set from clique

Independent Set from CLIQUE

  • 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. GG’ is O(n)

G’=(V,E’)

G=(V,E)

Largest Clique

Largest IS


Vertex cover from independent set

Vertex Cover (from Independent Set)

  • 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


More np complete problems

More NP-Complete Problems

  • 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.


More np complete problems1

More NP-Complete Problems

  • 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.


  • Login