1

Normally the TSP solution is the one so that the total cost on edges is minimal.

However in my case I need a specific edge on the solution, it does not matter if it the solution is not optimal anymore.

It does matter, however, that of all Hamiltonian cycles containing that edge the obtained solution is optimal. Or at least bounded.

More formally the problem would be: given a complete metric graph and a specific edge, what is the Hamiltonian cycle which cost is minimal passing through that specific edge?

Edit: transform the graph is probably a good idea. But keep in mind the resulting graph must still be metric and complete. A non-complete graph is equivalent to a non-metric one in this case, just think that the missing edge is actually an overly expensive one. This is important because there cannot be polinomial-time algorithm for general distances. If you are curious the proof of this fact is in "P-complete approximation problems" of S. Sahni and T. Gonzalez (1976).

Paolo.Bolzoni
  • 2,416
  • 1
  • 18
  • 29
  • Couldn't you do this by breaking the problem into two pieces? If the edge that must be included is A-B, then shortest path from start to A, then shortest path from B to finish. Then combine the two paths. – Krease Feb 12 '14 at 17:35
  • My bad, I meant cycles not paths. I edited. However, how do you combine the two solutions? Short-cutting? – Paolo.Bolzoni Feb 12 '14 at 17:40
  • Break the edge with an additional vertex. – n. m. could be an AI Feb 12 '14 at 17:45
  • Combining them depends on what info you need - path distance? Nodes travelled? Honestly, my memory of how to do this graph stuff is a bit fuzzy; it's been several years since I've had to use it. This probably isn't the optimal solution (you might need to cover B-A as well if direction is not important), but it might be enough to get you going. – Krease Feb 12 '14 at 17:47
  • @n.m. the graph must be complete and metric. Your idea is not applicable. – Paolo.Bolzoni Feb 12 '14 at 17:56
  • Does your TSP solver require a complete metric graph? – n. m. could be an AI Feb 12 '14 at 18:04
  • As far as I know in case of general distances there can't be a polynomial-time algorithm for TSP. Is it wrong? – Paolo.Bolzoni Feb 12 '14 at 18:09
  • Ok my idea with breaking the edge doesn't quite work. Here's a different one. You can find a solution that does not include the special edge, and then modify it such that the total cost is increased by no more than the weight of the special edge. It will not necessarily be optimal but close. – n. m. could be an AI Feb 13 '14 at 08:14

2 Answers2

1

How about making that edge's cost low enough that no Hamiltonian cycle that contains it could be more costly than a Hamiltonian cycle that does not contain it?

Let S be the sum of all distances in the graph. Add 2*S to every edge's cost, except the fixed one. That way every Hamiltonian cycle that contains the fixed edge will have cost at most (N-1)*2*S+S, and every cycle that does not contain it will have cost at least N*2*S.

The triangle inequality is also preserved, since every triangle (x, y, z) becomes either (x+2*S, y+2*S, z+2*S) or (x, y+2*S, z+2*S).

Anton
  • 3,113
  • 14
  • 12
  • Low enough might be a good idea, but you cannot go too low without losing the triangle inequality. – Paolo.Bolzoni Feb 12 '14 at 21:54
  • @Paolo.Bolzoni I edited the answer to add an example that keeps the graph metric. – Anton Feb 12 '14 at 22:25
  • An approximation algorithm is not guaranteed to find the shortest path, only one that's close enough (say, differs from the optimum no more than by factor of 1+epsilon). If you increase distances by a huge number like in your solution, *every* path may fall within 1+epsilon from the optimal. So it's only good if you can find the exact solution. – n. m. could be an AI Feb 13 '14 at 06:49
  • n.m. has a point, however the classic TSP approximation uses the minimum spanning tree. So it is only needed to increase the cost of the other edges so that the (s,d) is minimal and so part of the mst. I think I can work with this idea. – Paolo.Bolzoni Feb 13 '14 at 13:43
0

If X-Y is the edge, you can introduce a new vertex Z such that Z is connected only to X and Y, and remove X-Y. Distance(X,Z) + Distance(Z,Y) = Distance(X,Y).

ElKamina
  • 7,747
  • 28
  • 43