7

For my case I have starting point and several cities.

I want the shortest route to visit all cities without returning starting point.

I have read several TSP algorithm and all include the return a full cycle.

So what TSP variation should I look for to solve my problem?

Raphael
  • 73,212
  • 30
  • 182
  • 400

2 Answers2

6

You can reduce to a normal TSP variant by adding a dummy city that is distance $0$ away from each of the existing cities. (See also this answer on StackOverflow.)

Edit: it seems that my suggested modification is not quite appropriate: as I understand it, your Hamiltonian path has a fixed starting point but no fixed end point. One way to solve this is to add two dummy cities $v$ and $w$ such that:

  • $v$ is only connected to the starting point and to $w$,
  • $w$ is connected to everything.
Josse
  • 161
  • 1
  • 6
0

Turn it into an instance of the Hamiltonian $s-t$ path problem, as suggested in the comments of your original post.

Take your input graph and add two new vertices $s$ and $t$. Both of them should be connected to all other cities, but not to one another. All edges incident to $s$ or $t$ should be weighted 0.

Your 'salesman' can then start at $s$, visit all cities included on the original graph, and finish up at $t$.