refactor algorithms.tsp