I have been assigned a homework problem that I cannot figure out:

Prove that SAT has a polynomial-time reduction to the language of undirected non-negative weighted graphs with simple cycle of weight less that or equal to w.

This bears a resemblance to the all-pairs shortest path problem which has polynomial-time algorithms, but I've read multiple times that this problem is np-hard (plus, I suppose it would be a cruel trick to give such an assignment).

Starting from hamcycle, I have managed to produce a reduction for several variations on this problem (e.g., tsp, longest positive path, shortest negative path), but whenever it comes to this language I can always come up with a counterexample that invalidates my attempt at a reduction.

So, is there a reduction from SAT? What am I missing?


1 Answer 1


In the spirit of "give a man a fish, and he'll be fed for a day; teach a man to fish, and he never need be hungry again", I'll share with you some problem-solving techniques that might be helpful for approaching this problem (and other problems) -- but I'm not going to spoil it for you by solving your exercise for you.

Technique #1: If you don't know how to solve a problem, change the problem: look for "nearby"/"similar" problems you do know how to solve. If you can't reduce SAT to the original language, is there some related/variant language you can reduce SAT to? You may need to try multiple variants, and get a feeling for which ones you can easily find a reduction for and which ones you struggle with. This may give you some intuition about what the barrier/difficult part of your problem is, which may help you identify what aspect to focus your energy on.

Hint #1 (possible spoilers):

If you changed "less than or equal to w" to "equal to w", would the problem be any easier? What if you changed it to "greater than or equal to w"?

Technique #2: You can chain reductions. If you can reduce SAT to some variant, and reduce that variant to the original problem, you're in business.

Hint #2 (possible spoilers):

It seems that short cycles are a headache. If you have a graph $G$, can you think of some way to transform it to remove all short cycles (without changing whether or not it contains a cycle of length $w$)? (If you can't immediately see how to do it, can you write out a precise specification of what such an algorithm would need to do?)

And that's as much as I'm going to say. It's a good exercise, and it's your exercise, so you should have the chance to play around with it and discover a solution for yourself. It's tricky but doable.

  • $\begingroup$ Comment as answer because I don't have 50 reputation: I have no trouble making a reduction in the way you hint, in a few different ways. My problem is that that's as close as I can get - it's the "less than" part that I'm missing. $\endgroup$
    – user55570
    Commented Aug 2, 2016 at 1:32
  • $\begingroup$ @user55570, please don't use the 'answer' box to post comments or request clarification. If you've lost access to your original account, please create an account to ensure you retain access -- that way you'll be able to post comments in response to people's answers. Also, I encourage you to merge your two accounts. $\endgroup$
    – D.W.
    Commented Aug 2, 2016 at 4:44
  • $\begingroup$ Anyway, I edited my answer to provide some more problem-solving techniques. $\endgroup$
    – D.W.
    Commented Aug 2, 2016 at 4:44
  • 1
    $\begingroup$ Don't we already have a place for teaching how to fish? Maybe you want to add something there. $\endgroup$
    – Raphael
    Commented Aug 2, 2016 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.