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.
Related
Suppose you have been given a simple undirected graph and the graph has a max degree of d. You are given d + 1 colors, represented by numbers starting from 0 to d and you want to return a valid placement of colors such that no two adjacent vertices share the same color. And as the title suggests, the graph is given in adjacency list representation. The algorithm should run in O(V+E) time.
I think the correct way to approach this is by using a greedy coloring algorithm. However, this may sound stupid but I am stuck on the part where I try to find the first available color that hasn't been used by its neighbors for each vertex. I don't really know how I can do it so that it runs in O(number of neighbors) time for each vertex that helps to fit under time complexity requirements.
I'm taking the Algorithms: Design and Analysis II class, one of the questions asks:
Which of the following statements is true?
Consider a TSP instance in which every edge cost is either 1 or 2. Then an optimal tour can be computed in polynomial time.
Consider a TSP instance in which every edge cost is negative. The dynamic programming algorithm covered in the video lectures might not
correctly compute the optimal (i.e., minimum sum of edge lengths) tour
of this instance.
Consider a TSP instance in which every edge cost is negative. Deleting a vertex and all of its incident edges cannot increase the
cost of the optimal (i.e., minimum sum of edge lengths) tour.
Consider a TSP instance in which every edge cost is the Euclidean distance between two points in the place (just like in Programming
Assignment #5). Deleting a vertex and all of its incident edges cannot
increase the cost of the optimal (i.e., minimum sum of edge lengths)
tour.
I argue as follows:
The DP algorithm doesn't make any assumptions on the edge costs, so option 2 is incorrect.
If all edge weights are negative, then deleting a vertex and all of its incident edges can certainly increase the minimum sum because in effect, that edge weight is now added to the previous minimum. Thus, option 3 is incorrect.
Take the optimal tour in the original instance. Now, instead of visiting the deleted vertex v, skip straight from v's predecessor to its successor on the tour. Because Euclidean distance satisfies the "Triangle Inequality", this shortcut only decreases the overall distance traveled. The best tour can of course only be better. Thus, option 4 is correct.
However, I'm not able to find any significance for TSP problems with unit edge costs. Is option 1 merely a trick, or is there more to it?
OP here:
Papadimitriou and Yannakakis have shown that it is possible to approximate the TSP problem 1 in polynomial time within accuracy 7/6. This guarantee has been further improved by Bläser and Shankar Ram to 65/56. However, no matter how good those results are, those are still approximations, and not an optimal solution. Thus, option 1 is incorrect.
For simplication, we can assume that the graph G=(V,E) has 2N vertexes and the answer has N edges.
I have learned that if the graph is bipartite, Hungarian algorithm works well. However, I wonder if there is any nontrivial solution(i.e. a polynomial one) for a general graph.
Any polynomial solutions, as well as a proof of NP Complexity, are welcome.
If you want every vertex be incident to exactly one edge, then you need to find perfect matching. But perfect matching not always exists even for a graph with even number of vertices.
You can see example in this answer.
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.
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.