views:

195

answers:

2

Is there an algorithm or set of algorithms that would let you find the shortest walking distance from an arbitrary start node so that every node gets visited in a weight, undirected graph? It's not quite Traveling Salesman, because I don't care if a node is visited more than once. (It doesn't even matter if you make it back to the start -- the walker can end up in some far-off node as long as it was the last one needed to visit all nodes.) It's not quite minimum spanning tree, because it may be that going A-->B-->C-->A-->D is a (non-unique) shortest path to visit A, B, C, and D. My intuition says that this isn't quite an NP problem, because it doesn't have the restrictions that make NP problems so tricky. I could, of course, be completely wrong.

+8  A: 

From Wikipedia's article on Travelling Salesman Problem:

Removing the condition of visiting each city "only once" does not remove the NP-hardness, since it is easily seen that in the planar case there is an optimal tour that visits each city only once (otherwise, by the triangle inequality, a shortcut that skips a repeated visit would not increase the tour length).

Larry
Wiki is at least half wrong this time. Consider the weighted graph 1 -> 2 (1), 1 -> 3 (1), 1 -> 4 (1), 2 -> 3 (1000). If we can visit a city more than once, an optimal tool will avoid edge 2 -> 3 of cost 1000, so we can do for example 2 -> 1 -> 3 -> 1 -> 4. Or am I missing something?
IVlad
Well, that answers that, then.
Jon
Your example does not satisfy the "triangle inequality", which is implied by the "planar case" distinction.
Larry
True, sorry about that.
IVlad
Also, I think it's just showing a narrower case where the optimal is easy to visualize, not that it's a proof of the statement's correctness (since it doesn't work for planar TSP does not imply it doesn't work for all TSP).
Larry
+3  A: 

Not sure what the etiquette is to add an answer to a question with an already accepted answer.

I am adding this answer just for the sake of not having to jump to another page, to not have to deal with planar graphs and triangle inequality and the fact that this is simple and probably easier to understand.

Hamiltonian Path problem can be reduced to this:

Suppose we had a polynomial time algorithm to solve our problem of finding a least weight walk which visits all vertices.

Given a graph of which we need to decide a hamiltonian path exists or not, we just feed it as it is, to the problem algorithm at hand, setting edge weights = 1. If the algorithm returns a value > n-1, then there is no hamiltonian path in the original graph, else there is.

So this problem is NP-Hard.

Moron
Thanks -- this helps explain the problem further.
Jon