Jump to content

Nearest neighbour algorithm

From Simple English Wikipedia, the free encyclopedia
Revision as of 13:48, 10 February 2013 by Eptalon (talk | changes) (Created page with "'''Nearest neighbour algorithms''' is a the name given to a number of greedy algorithms to solve problems related to graph theory. In general, the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Nearest neighbour algorithms is a the name given to a number of greedy algorithms to solve problems related to graph theory. In general, these algorithms try to find a Hamlitonian circle as follows:

  1. Start at some vertex, at mark it as current.
  2. From the current vertex, take the shrtest edge that connects it to an unvisited vertex V.
  3. Set the current vertex to V.
  4. If there no unvisited vertices left, you are done.
  5. Else, go to step 2.

Such algoritms are easy to implement, but they do not always find the best solution. What is worse, the algorithm may not find a tour even if one exists.