Is it right that "it is NP-complete to determine if a graph contains a vertex cover of size 99"???
and
is it right that " it takes linear time to determine if a graph contains a vertex cover of size 99"???
One more, is it right to say that " No NP-complete problem can be solved in polynomial time unless the VERTEX COVER problem admits a polynomial-time algorithm."???
"is it NP-complete to determine if a graph contains a vertex cover of size 99"
Pedantically: no.
This problem can be solved in polynomial time. However, the following algorithm is completely useless in practice.
The approach for a graph with n vertices is simply to test all C(n,99) possible choices of vertex cover. For each choice, we test all edges (at most n*(n-1) edges in the graph) to see if either of their vertices are included.
There are fewer than n^99 ways of choosing the vertex cover, so overall this algorithm has polynomial complexity of n^101.
As noted by j_random_hacker, this answer assumes that the vertex size of 99 is a known constant. If the 99 is meant to be a variable and is part of the input, then the problem become the standard NP-complete vertex cover problem.
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 had a problem in my class quiz to write a non determinstic algorithm for Vertex Cover. We discussed about the solution with our instructor and he told that the level indeterminancy should not be too high. It should be sensibly good.
I am confused about what question should I ask to non-deterministic computer ?
The obvious question is "which vertex next"?
A simple greedy approximation algorithm for vertex cover repeatedly chooses the vertex with the most uncovered adjacent vertices.
A simple non-deterministic approximation algorithm for vertex cover repeatedly chooses the next vertex randomly, but with the probability assigned to each vertex proportional to its number of uncovered adjacent vertices. Do that over and over again, remembering the best solution so far.
For a given multigraph find the size of smallest set of vertices such that every vertex in multigraph is in set, or is connected with at least one vertex contained in set.
Can it be solved better than in O(2^n) ?
You might be able to optimize it slightly, but generally speaking - you cannot get sub-exponential time, this is the Vertex Cover Problem, which is known as NP-Hard, which means there is no known polynomial solution and the general belief is there is none.
http://en.wikipedia.org/wiki/Vertex_cover
As stated already, you can't solve this problem in polynomial time because it is NP-Hard. However, you can write an 2-approximation algorithm that runs in O(n^2) (which you can easily find on google).
Ex: http://www.codeproject.com/Articles/33735/The-Vertex-Cover-Problem
I have a graph, I want to walk through the graph (not necessary through all vertices), always taking path with greates weight. I cannot go through same vertex twice, I stop if there are no more moves I can make. What is the complexity? I assume it's "n" (where n is number of vertices) but I'm not sure.
If you can't go through the same vertice twice, your upper bound for edge traversals is n.
It's easy to think of examples where that would be a tight bound (a single chain of vertices connected for example).
However, keep in mind that complexity is for a given algorithm, not a general task, you haven't described your algorithm or how your graph is organized, so this question doesn't have any meaning.
If for example the graph is a clique, perhaps picking the highest weight edge for each traversal would itself take n computation steps (if the edges are kept in an unsorted list kept in each vertice), making the naive algorithm O(n^2) in this case. Other representations may have different complexity, but require different algorithms.
EDIT
If you're asking about finding the path with greatest overall weight (which may require you in some traversals to pick an edge that doesn't have the highest weight), than the problem is NP-hard. If it had a polynomial algorithm, then you could take an unweighted graph and find the longest path (a known NP hard problem as jimifiki pointed), and solve it with that algorithm.
From Longest Path Problem
This problem is called the Longest Path Problem, and is NP-complete.
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.