From d1d6fae5fdd16e6d8604433faa314028989d5c5e Mon Sep 17 00:00:00 2001 From: Mayank Mamgain <56592363+Mayank17M@users.noreply.github.com> Date: Thu, 9 Sep 2021 12:24:21 +0530 Subject: [PATCH 1/8] Update graph/travelling_salesman_problem.cpp Co-authored-by: David Leal --- graph/travelling_salesman_problem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/travelling_salesman_problem.cpp b/graph/travelling_salesman_problem.cpp index cc789b1e5..ebfa342ab 100644 --- a/graph/travelling_salesman_problem.cpp +++ b/graph/travelling_salesman_problem.cpp @@ -105,7 +105,7 @@ static void tests() { * @returns 0 on exit */ int main() { - tests(); + tests(); // run self-test implementations std::vector> cities = { {0, 5, 10, 15}, {5, 0, 20, 30}, {10, 20, 0, 35}, {15, 30, 35, 0}}; int V = cities.size(); From 88b0f27ed657da7d7ad94fcfd819ea63b409fa7b Mon Sep 17 00:00:00 2001 From: Mayank Mamgain <56592363+Mayank17M@users.noreply.github.com> Date: Fri, 10 Sep 2021 12:32:22 +0530 Subject: [PATCH 2/8] Update graph/travelling_salesman_problem.cpp Co-authored-by: David Leal --- graph/travelling_salesman_problem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/travelling_salesman_problem.cpp b/graph/travelling_salesman_problem.cpp index ebfa342ab..5138ee3b9 100644 --- a/graph/travelling_salesman_problem.cpp +++ b/graph/travelling_salesman_problem.cpp @@ -1,7 +1,7 @@ /** * @file * @brief [Travelling Salesman Problem] - * (https://en.wikipedia.org/wiki/Travelling_salesman_problem) + * (https://en.wikipedia.org/wiki/Travelling_salesman_problem) implementation * * @author [Mayank Mamgain](http://github.com/Mayank17M) * From cb8b0ee89774102d93dda9bee2f8d0da1127e670 Mon Sep 17 00:00:00 2001 From: Mayank Mamgain <56592363+Mayank17M@users.noreply.github.com> Date: Fri, 10 Sep 2021 12:32:36 +0530 Subject: [PATCH 3/8] Update graph/travelling_salesman_problem.cpp Co-authored-by: David Leal --- graph/travelling_salesman_problem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/graph/travelling_salesman_problem.cpp b/graph/travelling_salesman_problem.cpp index 5138ee3b9..a9357a9af 100644 --- a/graph/travelling_salesman_problem.cpp +++ b/graph/travelling_salesman_problem.cpp @@ -17,8 +17,7 @@ * This is the naive implementation of the problem. */ -#include /// header for limits of integral types - +#include /// for limits of integral types #include /// for std::min #include /// for assert #include /// for IO operations From 578852244444b038ff30728c2767bfe15e26d73a Mon Sep 17 00:00:00 2001 From: Mayank Mamgain <56592363+Mayank17M@users.noreply.github.com> Date: Fri, 10 Sep 2021 12:32:44 +0530 Subject: [PATCH 4/8] Update graph/travelling_salesman_problem.cpp Co-authored-by: David Leal --- graph/travelling_salesman_problem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/travelling_salesman_problem.cpp b/graph/travelling_salesman_problem.cpp index a9357a9af..bf5fe635b 100644 --- a/graph/travelling_salesman_problem.cpp +++ b/graph/travelling_salesman_problem.cpp @@ -83,7 +83,7 @@ static void tests() { {0, 20, 42, 35}, {20, 0, 30, 34}, {42, 30, 0, 12}, {35, 34, 12, 0}}; int V = cities.size(); assert(graph::TravellingSalesmanProblem(&cities, 0, V) == 97); - std::cout << "Test 1 Passed..." << std::endl; + std::cout << "1st test passed..." << std::endl; std::cout << "Initiating Test 2..." << std::endl; cities = {{0, 5, 10, 15}, {5, 0, 20, 30}, {10, 20, 0, 35}, {15, 30, 35, 0}}; From 33867bb94877c8da1f2f580035944ce56302291d Mon Sep 17 00:00:00 2001 From: Mayank Mamgain <56592363+Mayank17M@users.noreply.github.com> Date: Fri, 10 Sep 2021 12:32:51 +0530 Subject: [PATCH 5/8] Update graph/travelling_salesman_problem.cpp Co-authored-by: David Leal --- graph/travelling_salesman_problem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/travelling_salesman_problem.cpp b/graph/travelling_salesman_problem.cpp index bf5fe635b..5e9adcdc0 100644 --- a/graph/travelling_salesman_problem.cpp +++ b/graph/travelling_salesman_problem.cpp @@ -89,7 +89,7 @@ static void tests() { cities = {{0, 5, 10, 15}, {5, 0, 20, 30}, {10, 20, 0, 35}, {15, 30, 35, 0}}; V = cities.size(); assert(graph::TravellingSalesmanProblem(&cities, 0, V) == 75); - std::cout << "Test 2 Passed..." << std::endl; + std::cout << "2nd test passed..." << std::endl; std::cout << "Initiating Test 3..." << std::endl; cities = { From a65e85e79a1a570d14c55c8880c04bbf87b2e907 Mon Sep 17 00:00:00 2001 From: Mayank Mamgain <56592363+Mayank17M@users.noreply.github.com> Date: Fri, 10 Sep 2021 12:32:59 +0530 Subject: [PATCH 6/8] Update graph/travelling_salesman_problem.cpp Co-authored-by: David Leal --- graph/travelling_salesman_problem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/travelling_salesman_problem.cpp b/graph/travelling_salesman_problem.cpp index 5e9adcdc0..1cf5466c8 100644 --- a/graph/travelling_salesman_problem.cpp +++ b/graph/travelling_salesman_problem.cpp @@ -96,7 +96,7 @@ static void tests() { {0, 10, 15, 20}, {10, 0, 35, 25}, {15, 35, 0, 30}, {20, 25, 30, 0}}; V = cities.size(); assert(graph::TravellingSalesmanProblem(&cities, 0, V) == 80); - std::cout << "Test 3 Passed..." << std::endl; + std::cout << "3rd test passed..." << std::endl; } /** From 42f77148e57675f3cc5d2dda3902ab59b8529d3b Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 10 Sep 2021 07:03:44 +0000 Subject: [PATCH 7/8] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index b34e8afe6..f19f1c8ac 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -122,6 +122,7 @@ * [Prim](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/graph/prim.cpp) * [Topological Sort](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/graph/topological_sort.cpp) * [Topological Sort By Kahns Algo](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/graph/topological_sort_by_kahns_algo.cpp) + * [Travelling Salesman Problem](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/graph/travelling_salesman_problem.cpp) ## Graphics * [Spirograph](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/graphics/spirograph.cpp) From 9951dcd5acd68b86edfcf9636dd6b5779da66e4a Mon Sep 17 00:00:00 2001 From: Mayank Mamgain <56592363+Mayank17M@users.noreply.github.com> Date: Fri, 10 Sep 2021 12:34:19 +0530 Subject: [PATCH 8/8] Update graph/travelling_salesman_problem.cpp Co-authored-by: David Leal --- graph/travelling_salesman_problem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/graph/travelling_salesman_problem.cpp b/graph/travelling_salesman_problem.cpp index 1cf5466c8..dc911f565 100644 --- a/graph/travelling_salesman_problem.cpp +++ b/graph/travelling_salesman_problem.cpp @@ -38,7 +38,6 @@ namespace graph { * @param V number of vertices in the graph * */ - int TravellingSalesmanProblem(std::vector> *cities, int src, int V) { //// vtx stores the vertexs of the graph