Skip to content

MRo47/algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

Algorithms

When you have no life other than solving these on weekends.

Travelling salesman problem (TSP)

| C | O | O | C |
| O | S | O | O |
| O | O | O | H |
| C | O | O | O |

Finding the optimal path (minimum distance) a Salesman (S) has to travel between multiple cities (C) in a grid before getting home (H).

Solved using dynamic programming approach where a solution is guranteed. The python code should be able to solve for any grid size, for any number of cities.

The names are mapped to integer values for keeping the solution general to any such problem.

The problem can be represented as an undirected weighted graph since every city is connected to every other city where the cities can be represented as nodes of the graph and the distances between them as the weights.

Graph key

S = 1

H = 2

Cities (C) = 3,4,5

tsp_graph

The solution can then be formulated as below.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages