qwerji

naive traveling salesperson

edit the code

This is the “naive” or “brute-force” approach to the traveling salesperson algorithm. This is extremely inefficient at finding a solution.

  1. The distance between the cities is calculated and compared with the current shortest.
  2. Two members of the array are swapped, and the process repeats.

The green line is the best fit so far.

tags: code, p5