Nearest Neighbor algorithm for the Travelling Salesman Problem

Computes and plots the shortest path for the random 10-city Travelling Salesman Problem.

Sie verfolgen jetzt diese Einreichung

The 2-column vector contains cities' coordinates. The algorithm generates the optimal path to visit all the cities exactly once, and return to the starting city.
Do for all the cities:
1. select a city as current city.
2. find out the shortest edge connecting the current city and an unvisited city.
3. set the new city as current city.
4. mark the previous current city as visited.
5. if all the cities are visited, then terminate.
6. Go to step 2.

The algorithm has its limitations, and based on the cities' distribution on the map it may or may not give the optimal solution.

It resolves the problem of the equally distant cities, that some other submitted files had.

Zitieren als

ajevtic (2026). Nearest Neighbor algorithm for the Travelling Salesman Problem (https://de.mathworks.com/matlabcentral/fileexchange/25542-nearest-neighbor-algorithm-for-the-travelling-salesman-problem), MATLAB Central File Exchange. Abgerufen .

Allgemeine Informationen

Kompatibilität der MATLAB-Version

  • Kompatibel mit allen Versionen

Plattform-Kompatibilität

  • Windows
  • macOS
  • Linux
Version Veröffentlicht Versionshinweise Action
1.1.0.0

The algoritm implementation logic added in the description.

1.0.0.0