HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Is it possible to detect a simple negative-weight cycle of weight $N$ in polynomial time?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
cyclesimplepolynomialweighttimepossiblenegativedetect

Problem

Given a directed graph and an integer $N$, is it possible to detect a simple negative-weight cycle whose edges sum to $N$ in polynomial time? I thought about modifying the Floyd-Warshall algorithm to check if the diagonals equal $N$ as they get set, but I realized this wouldn't work if a vertex appeared in multiple negative-weight cycles.

Solution

No, there isn't (not unless P=NP). Take an unweighted directed graph on $n$ vertices, and set all of the edge weights to $-1$. Now there is a simple cycle of weight $-n$ if and only if there is a Hamiltonian circuit in the original graph. But detecting the existence of Hamiltonian circuits is NP-hard. Therefore your problem is NP-hard, too.

Context

StackExchange Computer Science Q#91720, answer score: 5

Revisions (0)

No revisions yet.