Travelling salesman variation in python

Josiah Carlson jcarlson at uci.edu
Fri Apr 2 15:25:57 EST 2004


> The problem is that all nodes are connected to all the other nodes, and 
> the weights are in essence random.. So it won't be possible to find 
> leftmost/rightmost point.

Give them arbitrary x,y positions in 2D space.  Whenever you see 
something like |p1p2|, that is asking the distance between those two 
vertices, and you can make that a lookup into your weight table or a 
call to your weight function.

If you look at the algorithm, the only thing that sorting the points in 
ascending order based on their x location is doing, is breaking up the 
problem into the left to right to left.  You can use whatever weights 
you want, and because of the way the problem is constructed, you're 
going to be checking all possible left to right to left paths on your 
way, so you'll find the 'optimal' in your case, bitonic TSP.

  - Josiah



More information about the Python-list mailing list