Questions tagged [np]

NP ("nondeterministic polynomial") is a complexity class of decision problems that can be solved by a nondeterministic Turing machine in polynomial time. Equivalently, it is the set of decision problems for which an answer can be verified in polynomial time by a deterministic Turing machine.

NP (nondeterministic polynomial-time) is a complexity class of decision problems that can be solved by a nondeterministic Turing machine in polynomial time. Equivalently, it is the set of decision problems for which an answer can be verified in polynomial time by a deterministic Turing machine.

For example:

  • 3-Colorability: Given a graph, can each vertex be colored red, green, or blue so that no two neighboring vertices have the same color?
  • Hamiltonian Cycle: Given a graph, is there a cycle that visits each vertex exactly once?
  • Traveling Salesperson: Given a set of n cities, and the distance between each pair of cities, is there a route that visits each city exactly once before returning to the starting city, and has length at most T?
  • Maximum Clique: Given a graph, are there k vertices all of which are neighbors of each other?
  • Subset Sum: Given a collection of integers, is there a subset of the integers that sums to exactly

References

492 questions
0
votes
1 answer

Spanning Trees with minimum number of leaves

So my problem is the following: I have an undirected (complete) weighted graph G=(V,E), and I would like to generate all the possible spanning trees with minimum number of leaves, i.e. with minimum number of vertices of degree 1. Let's call this…
user7427473
  • 3
  • 1
  • 2
0
votes
1 answer

ASP Clingo - splitting graph to n cliques

For a given graph i need to represent it using at most n cliques. I have problem with this task. This is similar to n-coloring of graph which is opposite of given graph (Graph b is opposite of graph A when if edge(a, b) in graph A than edge(a, b)…
domandinho
  • 1,260
  • 2
  • 16
  • 29
0
votes
2 answers

How does NP-Complete compare to NP-Hard?

So from what I understand: NP are problems that can be easy to solve and verify (ie: multiplication) NP-Hard are problems that are hard to solve but easy to verify (factoring) What is NP-Complete? The answers I find online say it's almost like…
penu
  • 968
  • 1
  • 9
  • 22
0
votes
1 answer

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…
sv_jan5
  • 1,543
  • 16
  • 42
0
votes
0 answers

NP hardness proof for scheduling algorithm

Suppose I have N packets; and M users (M>N). Each packet has a value to offer to each user. Each user has a demand. We need to distribute the packets to users such that users are maximally satisfied. Each packet can be assigned to only one…
jayanth a
  • 3
  • 3
0
votes
1 answer

Find the maximum vertex-disjoint path cover

Suppose I have a directed graph with weights on each node. The weight of a path between any two nodes is defined as the following: sum of all nodes in the path and multiply by the number of nodes in that path. We want to find a vertex-disjoint path…
YUE SHE
  • 3
  • 1
0
votes
1 answer

The connection between NP and Decision Pro

State T/F. If someone proves P = NP, then it would imply that every decision problem can be solved in polynomial time. I think it is false. Am I right?
sower
  • 71
  • 1
  • 5
0
votes
1 answer

Is reduction possible from P to NP?

If X is poly-time reducible to Y, we can not say anything about X, even if Y is NP-hard, so there must exist some polytime solvable problems which can be reduced to some NP-hard problems. Can someone provide some examples of it?
0
votes
1 answer

Np.concatenate ValueError: all the input arrays must have same number of dimensions

I am trying to concatenate but ended up with the mentioned error. Am also new to python. def cving(x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, ind1, ind2, ind3, ind4, ind5, num): if num == 0: xwhole = np.concatenate((x2, x3, x4, x5), axis=0) …
0
votes
2 answers

Solve Travelling Salesman once you know the distance of the shortest possible route

I am trying to solve the TSP (Travelling Salesman Problem), but not in a traditional way. I am following these steps. 1) First I change the TSP to a true / false problem. The definition of this problem is now: "Is there a route by all the cities…
Santiago Gil
  • 1,292
  • 7
  • 21
  • 52
0
votes
1 answer

finding an equal partition of a set given a black box which returns true if there exists one

during my exam preparation, i have found this question which i am unable to solve nor find a solution on the web. I have been struggling for a couple of hours trying to figure this one out with no luck. the problem goes as follows: given a black box…
Shak
  • 418
  • 1
  • 4
  • 14
0
votes
2 answers

Appending a dataframe Pandas

Can't seem to do this at all. So I have df.Name.unique() Which spits out a list of names. ['BKH' 'EDE'] And I have new = pd.DataFrame(columns=['Name']) And I want to append new to essentially have a list of names to put into new (column =…
entercaspa
  • 674
  • 2
  • 7
  • 19
0
votes
0 answers

Problems while reshaping previous np.ravel

Good evening, I've got a problem at my code; I wanna apply something (Pyneb ®) into a matrix (74 x 95). I've also defined some of my variable as np.nan, in case their value are equal or less then data error. However, when writing it to np.ravel(R),…
0
votes
1 answer

How reduction is used to prove hardness through contradiction?

I'm not a student taking a computational complexity course, just interested in the subject. I came across this section: Suppose we have a problem that we've proven is hard to solve, and we have a similar new problem. We might suspect that it is…
rb612
  • 5,280
  • 3
  • 30
  • 68
0
votes
1 answer

How 5-vertex cover is in P?

If 5-vertex cover is in P with O(n^5), then 100 vertex cover is in P with O(n^100) - so generally we can say vertex cover problem is in P! But why is the vertex cover problem in NP?
monabiyan
  • 9
  • 2