An algorithm to solve a traveling salesman problem