Nearest neighbour algorithm

This is an old revision of this page, as edited by 213.18.146.141 (talk) at 05:38, 26 February 2002 (*wrote article). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The nearest neighbour algorithm was one of the first algorithms used to determine a solution to the travelling salesman problem, and usually comes to within twenty percent of the optimal route. It is, however, a lot faster than testing every route.

These are the steps of the algorithm:

1. Make two sets of nodes, set A and set B, and put all nodes into set B 2. Put your starting node into set A 3. Pick the node which is closest to the last node and is not in set A; put this node into set A 4. Repeat step 3 until all nodes are in set A