permutation

Is there an algorithm for computing permutation of distances?

This is related to travelling salesman problem. First all permutations need to be generated and then the destination (same as origin) attached. I.e.: 1) abcd abdc .... 2) abcda abdca ....a I have all the distances and only need an algorithm to sum them up. I wonder if there is an algorithm (C preferable) I can use for this or if there ...

algorithm for functions permutating integers

Hi, I want to write a function y = f(x) and another function x = g(y) that acts as a reversible, where y = f(g(y)) and where x and y are permutated integers. For very simple example in the range of integers in 0 to 10 it would look like this: 0->1, 1->2, 2->3,..., 9->10, 10->0 but this is the simplest method by adding 1 and reversin...