Consider the TSP algorithms that we wrote:
def tsp(cities, paths, dist):
perms = permutations(cities)
for perm in perms:
total_dist = 0
for i in range(1, len(perm)):
total_dist += paths[perm[i - 1]][perm[i]]
if total_dist < dist:
return True
return False
def verify_tsp(paths, dist, actual_path):
total = 0
for i in range(len(actual_path)):
if i != 0:
total += paths[actual_path[i-1]][actual_path[i]]
return total < dist