Nearest Neighbor algorithm for the Travelling Salesman Problem

Versione 1.1.0.0 (2,51 KB) da ajevtic
Computes and plots the shortest path for the random 10-city Travelling Salesman Problem.
3,3K download
Aggiornato 12 ago 2014

Visualizza la licenza

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.

Cita come

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

Compatibilità della release di MATLAB
Creato con R2008b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.1.0.0

The algoritm implementation logic added in the description.

1.0.0.0