-2

I'm working on a question required to solve a variation of traveling salesman problem. What's different is that the origin can be different from destination, I would like to ask if there is any good implementation of this problem because most of the solution that I find always has a assumption that origin is the destination.

user2534365
  • 215
  • 1
  • 2
  • 10
  • Why would a salesman travel to his destination if he is already there? – Mathemats Mar 11 '16 at 05:05
  • I think this is equivalent to having a zero-cost edge between your source and destination, then deleting that edge after finding the solution. – Vaughn Cato Mar 11 '16 at 05:10
  • I may not express my questions clearly, what I'm trying to say is that there are waypoints I must pass through the path, but origin and destination are different. And Google in fact provided API exactly like this but I just want my implementation because Google has limitation on the number of waypoints – user2534365 Mar 11 '16 at 05:42

1 Answers1

1

If negative weight edges are allowed, you can add an edge, from the destination to the origin, with a sufficient minimal weight (for example, -10000000000). Then you can solve the problem using the implementation you find. The result must be a circle and must include the added edge. Removing the added edge result in a solution to the variant salesman problem.

Ke Yang
  • 218
  • 1
  • 6