tsp.py: Calculate optimal TSP cost