Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

Hi all!

I have an array of points with their coordinates X and Y. Each point represents a bus stop. I need to sort the points in a sequence by giving them sequence numbers, so that the path from the first to the last is the shortest.

For a convention, let's call the array "points", so we access and write by calling

point(i) for the point
point(i)(x) and point(i)(y) for the coordinates
point(n) is the sequence number.

It's also possible to use the for each loop:

for each point in points
point(x)
point(y)
point(n) 

The sequence needs to go through all the points of the array. I searched a lot on the internet, and the only thing I could find is Dijkstra's algorithm, which is not exactly what I look for, since I need to go through all the points.

It would be great if one of you guys knew something about that...

Thank's a lot.

Julien

share|improve this question
    
I added the graph theory tag. –  Tony Huynh May 23 '10 at 22:54

1 Answer 1

up vote 5 down vote accepted

If you only care about the length of the path between the first and last bus stops, then it looks like you are trying to solve the shortest Hamiltonian path problem (HPP). This is related to the more widely studied traveling salesman problem, see TSP. Since your points actually lie in the plane, you are considering the special case of the Euclidean Hamiltonian path problem. For Euclidean TSP, there is a polynomial-time approximation scheme, so I am guessing that the same is true for Euclidean HPP. Also, there are some heuristics based on neural networks, that appear to work well. See this paper.

share|improve this answer
    
Thank's, you're so helpful ! (I can't vote up since i don't have 15 reputation...) –  Julien May 24 '10 at 0:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.