I thought that, when proving that a problem P is NP-Complete, we were supposed to reduce a known NPC problem to P. But, looking at the solution to the Independent Set problem, it seems to not go this way.
To prove that Independent Set is NP-Complete, you take a graph G, find its inverse G', and then compute CLIQUE(G'). But, this is doing the other way around: it's taking a problem P I DON'T know if it's NPC and then reduces it to a know NPC problem.
Here's an example of the solution.
What am I missing here? Isn't this wrong, since it's doing it the other way around?
To prove that P is NP-complete, we need to show two things:
That P exists in NP.
That there's a polytime reduction algorithm to reduce some NP-complete problem Q to P.
If we know that CLIQUE is in NPC, then we can easily prove that IS is in NPC.
We can verify IS trivially in polytime. Iterate vertices, ensure that each has an edge not in the candidate solution.
We now need to reduce CLIQUE to IS. Given a graph G and an integer n, for CLIQUE we want to check if there's a CLIQUE of size n. Let H be the inverse of G. If you find an IS in H of size n, you have a CLIQUE of size n in G with the same vertices. We've reduced CLIQUE to IS.
If you were to reduce IS to CLIQUE, you wouldn't prove that either is in NPC unless you could reduce some other problem in NPC to IS.
I think this page may help you http://mlnotes.com/2013/04/29/npc.html
Related
I have been trying to find out a polynomial-time algorithm to solve this problem, but in vain. I'm not familiar with the NP-complete thing. Just wondering whether this problem is actually NP-complete, and I should not waste any further effort trying to come up with a polynomial-time algorithm.
The problem is easy to describe and understand. Given a bipartite graph, what is the minimum number of vertices you have to select from one vertex set, say A, so that each vertex in B is adjacent to at least one selected vertex.
Unfortunately, this is NP-hard; there's an easy reduction from Set Cover (in fact it's arguably just a different way of expressing the same problem). In Set Cover we're given a ground set F, a collection C of subsets of F, and a number k, and we want to know if we can cover all n ground set elements of F by choosing at most k of the sets in C. To reduce this to your problem: Make a vertex in B for each ground element, and a vertex in A for each set in C, and add an edge uv whenever ground element v is in set u. If there was some algorithm to efficiently solve the problem you describe, it could solve the instance I just described, which would immediately give a solution to the original Set Cover problem (which is known to be NP-hard).
Interestingly, if we are allowed to choose vertices from the entire graph (rather than just from A), the problem is solvable in polynomial time using bipartite maximum matching algorithms, due to Kőnig's Theorem.
I want to summarize some problem on Complexity. Which of them can be solved in poly-time?
I) finding maximal sub complete graph of given graph = Clique Problem
II) select some elements among n objects in which value and weights
are given, such that sum of weights of selected elements is not bigger
than an specific bound and sum of value being maximum
III) finding all cycles of a graph
IV) Finding a path that visit each vertex exactly once = Determine a graph is Hamiltonian
I think IV is Hamiltonian path that is NP-Complete, III is NP-Hard and NP-Complete, II is NP-Complete, and I is NP-Complete. so 0 of these solved in poly-time.
Who can more clearer me about NP-Hard and NP-Complete of these problem in a nice way? Am I right?
As you've noted, parts (1), (2), and (4) are all famous NP-hard problems (max clique, knapsack, and Hamiltonian path). These problems are not in NP, though, because NP consists of decision problems (questions for which the answer is either "yes" or "no") and these are not decision problems.
Part (3) is more nuanced. This problem is a counting problem - the goal is to determine how many objects of some type exist - rather than a decision problem, so it can't be in NP. To the best of my knowledge, it's not really known how hard this problem is. It's known that if it can be solved in polynomial time, then P = NP (see this link for details), and the specific proof shows that it's NP-hard as well.
If P ≠ NP, then none of these can be solved in polynomial time. If any of these can be solved in polynomial time, then P = NP. They are all NP-hard.
Hope this helps!
Because I got asked about a reference, I am posting my comment as the answer:
II) select some elements among n objects in which value and weights
are given, such that sum of weights of selected elements is not bigger
than an specific bound and sum of value being maximum
This is a knapsack problem which is poly-time if weights are not a part of input size, i.e the solution is polynomial in terms of n only.
It runs in O(n * W) where W is the maximum allowed weight. Of course this can be not polynomial if W is related to n, for example if W = 2^n.
You can read about it here:
http://en.wikipedia.org/wiki/Knapsack_problem#Dynamic_programming_in_advance_algorithm
http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Dynamic/knapsackdyn.htm
We know that the minimum vertex cover is NP complete, which means that it is in the set of problems that can be verified in polynomial time.
As I understand it, the verification process would require the following:
Verify that the solution is a vertex cover at all
Verify that the solution is the smallest possible subset of the source graph that satisfies condition #1
I'm finding it hard to establish that step #2 can be done in polynomial time. Can anyone explain how it is?
The minimum vertex cover is NP-hard. It is only NP-complete if it is restated as a decision problem which can be verified in polynomial time.
The minimum vertex cover problem is the optimization problem of finding a smallest vertex cover in a given graph.
INSTANCE: Graph G
OUTPUT: Smallest number k such that G has a vertex cover of size k.
If the problem is stated as a decision problem, it is called the vertex cover problem:
INSTANCE: Graph G and positive integer k.
QUESTION: Does G have a vertex cover of size at most k?
Restating a problem as a decision problem is a common way to make problems NP-complete. Basically you turn an open-ended problem of the form "find the smallest solution k" into a yes/no question, "for a given k, does a solution exist?"
For example, for the travelling salesman problem, verifying that a proposed solution the shortest path between all cities is NP-hard. But if the problem is restated as only having to find a solution shorter than k total distance for some k, then verifying a solution is easy. You just find the length of the proposed solution and check that it's less than k.
The decision problem formulation can be easily used to solve the general formulation. To find the shortest path all you have to do is ratchet down the value of k until there are no solutions found.
I have problem with scheduling. I need to prove that the problem is NP complete. What can be the methods to prove it NP complete?
To show a problem is NP complete, you need to:
Show it is in NP
In other words, given some information C, you can create a polynomial time algorithm V that will verify for every possible input X whether X is in your domain or not.
Example
Prove that the problem of vertex covers (that is, for some graph G, does it have a vertex cover set of size k such that every edge in G has at least one vertex in the cover set?) is in NP:
our input X is some graph G and some number k (this is from the problem definition)
Take our information C to be "any possible subset of vertices in graph G of size k"
Then we can write an algorithm V that, given G, k and C, will return whether that set of vertices is a vertex cover for G or not, in polynomial time.
Then for every graph G, if there exists some "possible subset of vertices in G of size k" which is a vertex cover, then G is in NP.
Note that we do not need to find C in polynomial time. If we could, the problem would be in `P.
Note that algorithm V should work for every G, for some C. For every input there should exist information that could help us verify whether the input is in the problem domain or not. That is, there should not be an input where the information doesn't exist.
Prove it is NP Hard
This involves getting a known NP-complete problem like SAT, the set of boolean expressions in the form:
(A or B or C) and (D or E or F) and ...
where the expression is satisfiable, that is there exists some setting for these booleans, which makes the expression true.
Then reduce the NP-complete problem to your problem in polynomial time.
That is, given some input X for SAT (or whatever NP-complete problem you are using), create some input Y for your problem, such that X is in SAT if and only if Y is in your problem. The function f : X -> Y must run in polynomial time.
In the example above, the input Y would be the graph G and the size of the vertex cover k.
For a full proof, you'd have to prove both:
that X is in SAT => Y in your problem
and Y in your problem => X in SAT.
marcog's answer has a link with several other NP-complete problems you could reduce to your problem.
Footnote: In step 2 (Prove it is NP-hard), reducing another NP-hard (not necessarily NP-complete) problem to the current problem will do, since NP-complete problems are a subset of NP-hard problems (that are also in NP).
You need to reduce an NP-Complete problem to the problem you have. If the reduction can be done in polynomial time then you have proven that your problem is NP-complete, if the problem is already in NP, because:
It is not easier than the NP-complete problem, since it can be reduced to it in polynomial time which makes the problem NP-Hard.
See the end of http://www.ics.uci.edu/~eppstein/161/960312.html for more.
In order to prove that a problem L is NP-complete, we need to do the following steps:
Prove your problem L belongs to NP (that is that given a solution you can verify it in polynomial time)
Select a known NP-complete problem L'
Describe an algorithm f that transforms L' into L
Prove that your algorithm is correct (formally: x ∈ L' if and only if f(x) ∈ L )
Prove that algo f runs in polynomial time
First, you show that it lies in NP at all.
Then you find another problem that you already know is NP complete and show how you polynomially reduce NP Hard problem to your problem.
Get familiar to a subset of NP Complete problems
Prove NP Hardness : Reduce an arbitrary instance of an NP complete problem to an instance of your problem. This is the biggest piece of a pie and where the familiarity with NP Complete problems pays. The reduction will be more or less difficult depending on the NP Complete problem you choose.
Prove that your problem is in NP : design an algorithm which can verify in polynomial time whether an instance is a solution.
"Prove that it is NP-Complete to determine given input G and k whether G has both a clique of size k and an independent set of size k. Note that this is 1 problem, not 2; the answer is yes if and only if G has both of these subsets."
We were given this problem in my algorithms course and a large group of students could not figure it out. Here is what we have so far...
We know that both the clique and independent set problems are NP-Complete in of themselves. We also know that the verification of this problem, given some "certificate" is in NP.
The problem is somehow performing a reduction on the above problem (which contains both independent sets and cliques) to either a problem consisting entirely of cliques or independent sets (at least that's what we think we need to do). We don't know how to perform this reduction without losing information needed to reduce the reduction back to its original form.
Hint: Reduce CLIQUE to this problem, by adding some vertices.
Thanks to "Moron" and "Rafal Dowgird" for the hints! Based on that I think I've got a solution. Please correct me if I am incorrect:
Since we already know the the clique and independent-set problems are NP-Complete, we can use that as a foundation for proving our problem. Let's call our problem the Combination Clique Independent Set problem (CCIS).
Suppose we are given a graph G which has a clique C of size k. We can reduce this graph into a graph G' (read: G prime) which has both a clique C' of size k' and independent-set I of size k' by attaching k vertices to each vertex in C. This reduction occurs in polynomial time since the addition of the vertices takes O(n*k) time (n vertices in the graph and k vertices attached to each node).
Note that C=C' and k=k'.
Now suppose we are given a graph G' which has a clique C' of size k' and independent-set I of size k' which is determined to be true. The reduction to the clique problem is trivial since we don't need to modify the graph at all to find only a clique.