# Reduction from SAT to shortest cycle?

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?

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.

• 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. – user55570 Aug 2 '16 at 1:32
• @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. – D.W. Aug 2 '16 at 4:44
• Anyway, I edited my answer to provide some more problem-solving techniques. – D.W. Aug 2 '16 at 4:44
• Don't we already have a place for teaching how to fish? Maybe you want to add something there. – Raphael Aug 2 '16 at 9:41