original qusetion only have 8 cities.
But?
if change it to 20, 30..
I have search the solution for it, but all i found was use permutation. permutation is good for 8 cities, but if the cities = 20, 30... It's slow, very slow.
So, my question is:
if it have 20 cities or more
what is your solution?
Indeed, this is a form of the traveling salesman, for which the running time of a simple algorithm is usually O(n!) (Or O(n*(n-1)*(n-2)*...*(1)).
The common solution is to calculate all possible paths and then compare, however there is also the Held-Karp algorithm, which performs slightly better.