简体   繁体   中英

Finding all possible simple path in an undirected graph is NP hard/ NP complete

The proof is needed:

Finding all possible simple path in an undirected graph is NP hard/ NP complete. The graph may contain multiple edges between same pair of nodes, and loops.

I have searched over, got some idea or discussion. But I need a direct proof/link stating the complexity is NPC/ NP-Hard.

Problems of the form "find all objects of some type" aren't NP-complete, because NP consists purely of decision problems , questions that have a yes/no answer. So this problem can't be NP-complete.

If you specifically have to list the paths in descending order of size, then the problem would be NP-hard. If you can list all paths in descending size order, then you can just check the first path to see if it passes through all nodes. If so, great, Your graph has a Hamiltonian path. and finding Hamiltonian paths is NP-hard.

On the other hand, if you listed the paths in ascending order of length, then assuming you're working with Turing machines the cost of simply reading all the paths to get to the last one would take more than polynomial time, so this reduction wouldn't work. A similar argument shows that this reduction won't work if the paths come back in arbitrary order. I suspect, but am not fully sure, that it's unknown whether that version of the problem is NP-hard, but I'm open to being corrected on that.

This is all the more interesting given that the number of simple paths in a graph can be O(n,). which happens when the graph is a complete graph (all pairs of nodes are linked by edges). The fact that something takes a long time to complete doesn't immediately mean that it's NP-hard or NP-complete.

Hope this helps!

The complexity of this problem appears to be O(n.) which is worse than the O(2^n) of the NP-Hard / NP-Complete series, Additionally. this is not NP-Hard / NP-Complete because it isn't even in NP.
Requirement for NP:
"A problem is called NP (nondeterministic polynomial) if its solution can be guessed and verified in polynomial time"[ 1 ]
Your problem is not in NP, since checking your solution has a complexity of O(n,) just like calculating your results, because in an (n-1)-Simplex (fully interconnected graph with n vertices)[ 2 ] the solution of all possible simple paths will be for(i = {1 to n}){sum(n!/(ni)!)} + 1 for the empty set paths (please look at templatetypedef's comment[ 3 ] for proof), which is O(n.) and more specifically does not fall into polynomial time solution. 例子
In the image above[ 4 ] you have an example of a 3 simplex.
Full enumeration will consist of for(i = {1 to 4}){sum(4:/(4-i)!)}+1 = (4!÷3!)+(4!÷2!)+(4!÷1!)+(4!÷0!)+1 = 65 paths:

{}

{A}
{A->B}
{A->B->C}
{A->B->D}
{A->B->C->D}
{A->B->D->C}
{A->C}
{A->C->B}
{A->C->D}
{A->C->B->D}
{A->C->D->B}
{A->D}
{A->D->B}
{A->D->C}
{A->D->B->C}
{A->D->C->B}

{B}
{B->A}
{B->A->C}
{B->A->D}
{B->A->C->D}
{B->A->D->C}
{B->C}
{B->C->A}
{B->C->D}
{B->C->A->D}
{B->C->D->A}
{B->D}
{B->D->A}
{B->D->C}
{B->D->A->C}
{B->D->C->A}

{C}
{C->B}
{C->B->A}
{C->B->D}
{C->B->A->D}
{C->B->D->A}
{C->A}
{C->A->B}
{C->A->D}
{C->A->B->D}
{C->A->D->B}
{C->D}
{C->D->B}
{C->D->A}
{C->D->B->A}
{C->D->A->B}

{D}
{D->B}
{D->B->C}
{D->B->A}
{D->B->C->A}
{D->B->A->C}
{D->C}
{D->C->B}
{D->C->A}
{D->C->B->A}
{D->C->A->B}
{D->A}
{D->A->B}
{D->A->C}
{D->A->B->C}
{D->A->C->B}

Hope this helps and good luck with solving this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM