NP-Complete and some decision problems on graph? - algorithm

We know about NP-Complete and NP-Hard, and NP Class. I want to conclude some tips on following problem, that take from 2008 Mid exam on MIT.
Decision Version of which of the following problem for a connected undirected weighted graph G is NP-Complete?
a) finding maximal matching.
b) finding maximum Hamiltonian cycle
c) finding maximum Eulelrian cycle
d) finding maximum cut
How can categorized these problem in a simple manner for me? i.e. NP or NP-Complete or NP-Hard.

There are poly-time algorithms for computing maximal matchings (e.g., greedy; Edmonds's Blossom algorithm computes a maximum matching in poly-time) and Eulerian cycles. The decision versions trivially belong to NP (P, in fact).
Hamilton cycle and max cut are well-known NP-hard problems. The decision versions are in NP so thus are NP-complete.

Related

Proving NP completeness of optimal path cover

This paper solves the optimal path cover problem for block graphs or bipartite permutation graph. In the third line of its introduction it's written that optimal path cover problem is NP-Complete and has given reference to "Computer and intractability: a guide to the theory of NP-completeness by David S. Johnson, Michael R. Garey". But I couldn't find its proof in the book. If anyone knows how to prove NP-Completeness of this problem then share your solution.
Optimal path cover problem:
Given a graph G, find a minimum number of
vertex disjoint paths which together cover all the vertices of the
graph.
Considering the obvious decision variant (ie given k, is there a cover with k paths)
OPC(k=1) detects Hamiltonian paths, so clearly it's NP-hard.
It's also in NP because given the paths, checking whether they're disjoint and covering is easy.

Why is TSP NP-hard while the Hamiltonian path NP-complete?

Why aren't these 2 problems, namely TSP and Hamiltonian path problem, both NP-complete?
They seem identical.
For a problem X to be NP-complete, it has to satisfy:
X is in NP, given a solution to X, the solution can be verified in polynomial time.
X is in NP-hard, that is, every NP problem is reduceable to it in polynomial time (you can do this through a reduction from a known NP-hard problem (e.g. Hamiltonian Path)).
There are two versions of the The Travelling Salesman Problem (TSP):
The optimization version (probably the one you are looking at), namely, find the optimum solution to the TSP. This is not a decision problem, and hence cannot be in NP, but it is however in NP-hard which can be proven via a Hamiltonian Path reduction. Therefore this isn't an NP complete problem.
The decision version - given an integer K is there a path through every vertex in the graph of length < K? This is a decision (yes/no) problem, and a solution can be verified in polynomial time (just traverse the path and see if it touches every vertex) and so it is in NP, but it is also in NP-hard (by an identical proof as above). Since it satisfies both requirements for NP-completeness, it is an NP-complete problem.
The definitions of NP-hardness and NP-completeness are related but different. Specifically, a problem is NP-hard if every problem in NP reduces to it in polynomial time, and a problem is NP-complete if it's both NP-hard and itself in NP.
The class NP consists of decision problems, problems that have a yes/no answer. As a result, TSP cannot be in NP because the expected answer is a number rather than yes or no. Therefore, TSP can be NP-hard, but it can't be NP-complete.
On the other hand, the Hamiltonian path problem asks for a yes/no answer, and it happens to be in NP. Therefore, since it's NP-hard as well, it's NP-complete.
Now, you can take TSP and convert it to a decision problem by changing the question from "what's the cheapest path?" to "is there a path that costs X or less?," and that latter formulation is in NP and also happens to be NP-complete.

Is there a polynomial algorithm to find the max weighted perfect matching in a general graph?

I see that Blossom algorithm can be used to solve the unweighted version of this problem, and I know that this problem can also be reduced to an LP problem (but with exponential numbers of constraints). Is there a way to solve it in polynomial time?
Yes, the Blossom algorithm for computing maximum unweighted general matchings can be used in a primal-dual algorithm for maximum weighted general matchings (this is a general technique; the Hungarian algorithm is the bipartite equivalent). There's an implementation called Blossom V due to Vladimir Kolmogorov.

Complexity of Some problems in NP?

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

Construct a minimum spanning tree covering a specific subset of the vertices

I have an undirected, positive-edge-weight graph (V,E) for which I want a minimum spanning tree covering a subset k of vertices V (the Steiner tree problem).
I'm not limiting the size of the spanning tree to k vertices; rather I know exactly which k vertices must be included in the MST.
Starting from the entire MST I could pare down edges/nodes until I get the smallest MST that contains all k.
I can use Prim's algorithm to get the entire MST, and start deleting edges/nodes while the MST of subset k is not destroyed; alternatively I can use Floyd-Warshall to get all-pairs shortest paths and somehow union the paths. Are there better ways to approach this?
There's a lot of confusion going on here. Based on what the OP says:
I'm not limiting the size of the spanning tree to k vertices; rather I know exactly which k vertices must be included in the MST.
This is the Steiner tree problem on graphs. This is not the k-MST problem. The Steiner tree problem is defined as such:
Given a weighted graph G = (V, E), a subset S ⊆ V of the vertices,
and a root r ∈ V , we want to find a minimum weight tree which connects all the vertices in S to
r. 1
As others have mentionned, this problem is NP-hard. Therefore, you can use an approximation algorithm.
Early/Simple Approximation Algorithms
Two famous methods are Takahashi's method and Kruskal's method (both of which have been extended/improved by Rayward-Smith):
Takahashi H, Matsuyama A: An approximate solution for the Steiner problem in graphs. Math. Jap 1980, 24:573–577.
Kruskal JB: On the Shortest Spanning Subtree of a Graph and the Traveling Salesman Problem. In Proceedings of the American Mathematical Society, Volume 7. ; 1956:48–50.
Rayward-Smith VJ, Clare A: On finding Steiner vertices. Networks 1986, 16:283–294.
Shortest path approximation by Takahashi (with modification by Rayward-Smith)
Kruskal's approximation algorithm (with modification by Rayward-Smith)
Modern/More Advanced Approximation Algorithms
In biology, more recent approaches have treated the problem using the cavity method, which has led to a "modified belief propagation" method that has shown good accuracy on large data sets:
Bayati, M., Borgs, C., Braunstein, A., Chayes, J., Ramezanpour, A., Zecchina, R.: Statistical mechanics of steiner trees. Phys. Rev. Lett. 101(3), 037208 (2008) 15.
For an application: Steiner tree methods for optimal sub-network identification: an empirical study. BMC Bioinformatics. BMC Bioinformatics 2013 30;14:144. Epub 2013 Apr 30.
In the context of search engine problems, approaches have focused on efficiency for very large data sets that can be pre-processed to some degree.
G. Bhalotia, A. Hulgeri, C. Nakhe, S. Chakrabarti, and S. Sudarshan. Keyword Searching and Browsing in Databases using BANKS. In ICDE, pages 431–440.
G. Kasneci, M. Ramanath, M. Sozio, F. M. Suchanek, and G. Weikum. STAR: Steiner-tree approximation in relationship graphs. In ICDE’09, pages 868–879, 2009
The problem you stated is a famous NP-hard problem, called Steiner tree in graphs. There are no known solutions in polynomial time and many believe no such solutions exist.
Run Prim's algorithm on the restricted graph (k, E') where E' = {(x, y) ∈ V : x ∈ k and y ∈ k}). Constructing that graph takes O(|E|).

Resources