views:

70

answers:

2

Suppose I have an n*n matrix of distances between n users. I'd like to know what algorithm to use in order to find a route around the group, beginning at user X and returning to user X, with all other nodes visited once but only once, and using the shortest possible distance in each hop.

+9  A: 

This problem is called the Travelling Salesman Problem. There is an excellent Wikipedia page on it that should point you in the right direction.

David M
Thanks very much! :)
ventolin
You're welcome.
David M
+2  A: 

This is Traveling Salesman Problem assuming that you want the total length of the tour to be minimized. NP-Complete, so no poly-time algoritm, but good approximation techniques exist.

Krystian