TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
[Travelling Salesman Problem] (https://en.wikipedia.org/wiki/Travelling_salesman_problem) implementation More...
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>
Go to the source code of this file.
Namespaces | |
namespace | graph |
Graph Algorithms. | |
Functions | |
int | graph::TravellingSalesmanProblem (std::vector< std::vector< uint32_t > > *cities, int32_t src, uint32_t V) |
Function calculates the minimum path distance that will cover all the cities starting from the source. | |
static void | tests () |
Self-test implementations. | |
int | main () |
Main function. | |
[Travelling Salesman Problem] (https://en.wikipedia.org/wiki/Travelling_salesman_problem) implementation
Travelling salesman problem asks: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? TSP can be modeled as an undirected weighted graph, such that cities are the graph's vertices, paths are the graph's edges, and a path's distance is the edge's weight. It is a minimization problem starting and finishing at a specified vertex after having visited each other vertex exactly once. This is the naive implementation of the problem.
Definition in file travelling_salesman_problem.cpp.
int main | ( | void | ) |
Main function.
Definition at line 105 of file travelling_salesman_problem.cpp.
|
static |
Self-test implementations.
Definition at line 78 of file travelling_salesman_problem.cpp.