I'm trying out a bunch of different algorithms for finding near-optimal solutions to the Traveling Salesman Problem, and one of the methods is the brute force approach - checking every possible path between n cities, and simply returning the best one. This is an O(n!) algorithm, so naturally it takes a very long time to execute for a large number of cities.
I want to improve the efficiency of my brute force implementation, and one of the things I've noticed is that you don't have to check every single permutation of the cities. For example, if you have cities 1, 2, 3, and 4, the path (1-2-3-4) is the same length as path (2-3-4-1). The same goes for the paths (3-4-1-2) and (4-1-2-3). By exploiting this fact, we should be able to reduce the complexity of the brute force algorithm from O(n!) to O((n-1)!), or even O((n-1)!/2) if we realize that all paths can be reversed without affecting their lengths.
Basically, I'm looking for an algorithm that is capable of generating circular permutations from a set of distinct integers. It would also be great if the algorithm treated "mirrored" permutations as equivalent (e.g. 1-2-3 and 3-2-1 are the same, so only one of them is needed). Does anyone know of a way to accomplish this? A Java implementation would be wonderful, but I'll take anything!