A Nearest Neighbor solution in Go to the Traveling Salesman Problem

A Nearest Neighbor solution in Go to the Traveling Salesman Problem

A Go implementation of the Nearest Neighbor algorithm is presented with charting of the path and supporting report output. This project is an approximate solution to the Traveling Salesman problem using a nearest neighbor(NN) algorithm. A very detailed analysis and discussion of this relatively famous Computer Science problem is covered in reference (4).

Summary

A Go implementation of the Nearest Neighbor algorithm is presented with the charting of the path and supporting report output. A circular set of Nodes shows the implementation is reasonably accurate for the algorithm. The project is hosted publicly on gitlab as noted in reference 6.

Introduction

This project is an approximate solution to the Traveling Salesman problem using a nearest neighbor(NN) algorithm. A very detailed analysis and discussion of this relatively famous Computer Science problem is covered in reference (4). This solution is believed to be within about 25% longer than the exact solution as noted by Wikipedia(4). This project is an exercise in implementing the NN algorithm in Go and possibly some improvements to the basic NN algorithm.

Notes

Notes about this project:

  1. It is apparent from a casual inspection of the output chart that the algorithm, while quick to execute, is less than ideal in terms of accuracy. Many test runs revealed this and has prompted some ideas for further testing.
  2. It might be possible to improve the accuracy by using a look ahead feature to consider two nodes rather than a single node in the NN algorithm.
  3. Another improvement might be to implement a circle such that nodes are selected by comparison to their distance from some point on the circle circumference.
  4. Code reorganization and chart improvements are anticipated.

The starting node does not affect the total distance traveled for any one set of Nodes. The reason is that the same set of edges gets selected since no change to the relative position of the nodes to one another affects the shortest distance to the next node for that node.

Once the algorithm was working the first question that comes to mind is how to prove it is working as designed. The first solution was to compute 26 nodes in the form of a 27 edge polygon, close enough to a circle to compare the Salesman’s route distance to a circle composed of the 27 edges. The circumference of the circle was computed and rounded to 314 while the salesman’s route was computed as 313.18.

search computer-science data-science

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

50 Data Science Jobs That Opened Just Last Week

Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments. Our latest survey report suggests that as the overall Data Science and Analytics market evolves to adapt to the constantly changing economic and business environments, data scientists and AI practitioners should be aware of the skills and tools that the broader community is working on. A good grip in these skills will further help data science enthusiasts to get the best jobs that various industries in their data science functions are offering.

Applications Of Data Science On 3D Imagery Data

The agenda of the talk included an introduction to 3D data, its applications and case studies, 3D data alignment and more.

Data Science With Python Training | Python Data Science Course | Intellipaat

🔵 Intellipaat Data Science with Python course: https://intellipaat.com/python-for-data-science-training/In this Data Science With Python Training video, you...

Data Science Course in Dallas

Become a data analysis expert using the R programming language in this [data science](https://360digitmg.com/usa/data-science-using-python-and-r-programming-in-dallas "data science") certification training in Dallas, TX. You will master data...

32 Data Sets to Uplift your Skills in Data Science | Data Sets

Need a data set to practice with? Data Science Dojo has created an archive of 32 data sets for you to use to practice and improve your skills as a data scientist.