Finding the minimal subgraph that contains all neg

2020-06-22 01:18发布

问题:

I'm stuck at the following problem: Given a weighted digraph G, I'd like to construct the minimal subgraph of G that contains all negative (simple) cycles of G.

I do know how to find a negative cycle using Bellman-Ford, and I know that the number of simple cycles in a directed graph is exponential.

One naive way to approach the problem would be to simply iterate all simple cycles and pick those that are negative, but I have the feeling that there might be a polynomial-time algorithm. Most articles that I found through Google were about finding a (rather than all) negative cycle.

I'm hoping to find some experts here on stackoverflow that may give some hints towards a polynomial-time solution, or hints towards proving that it can't be solved in polynomial time.

Many thanks in advance!

Cheers, Robert

回答1:

For anyone interested in or stuck at a similar problem: it's NP-complete. Thanks to wich for pointing me to the thread in cstheory.

To see why it's NP-complete, first of all observe that the problem may be stated as follows: given a weighted directed graph G with N verices and an edge E on G, find out whether E lies on a (simple) negative cycle. If it does, E should be in the subgraph H. If it does not, it should not be in H.

Now, let edge E be E = (u, v) with weight w. We'd like to know whether there's a path from v to u with total weight W such that W + w < 0. If we could do this in polynomial time, we could also solve the Hamiltonian Cycle problem in polynomial time:

Assign to edge E a weight of N - 1.00001. Assign to all other edges in the graph a weight of -1. Now the graph's only negative cycle on which E lies, is the cycle that contains all vertices (that cycle has weight -0.00001) and is thus a Hamiltonian Cycle.

Many thanks for thinking along!