int32_t src, uint32_t V) {
44std::vector<uint32_t> vtx;
45 for(uint32_t i = 0; i < V; i++) {
52int32_t min_path = 2147483647;
55int32_t curr_weight = 0;
60curr_weight += (*cities)[k][i];
63curr_weight += (*cities)[k][src];
66min_path = std::min(min_path, curr_weight);
68}
while(next_permutation(vtx.begin(), vtx.end()));
79std::cout <<
"Initiatinig Predefined Tests..."<< std::endl;
80std::cout <<
"Initiating Test 1..."<< std::endl;
81std::vector<std::vector<uint32_t>> cities = {
82{0, 20, 42, 35}, {20, 0, 30, 34}, {42, 30, 0, 12}, {35, 34, 12, 0}};
83uint32_t V = cities.size();
85std::cout <<
"1st test passed..."<< std::endl;
87std::cout <<
"Initiating Test 2..."<< std::endl;
88cities = {{0, 5, 10, 15}, {5, 0, 20, 30}, {10, 20, 0, 35}, {15, 30, 35, 0}};
91std::cout <<
"2nd test passed..."<< std::endl;
93std::cout <<
"Initiating Test 3..."<< std::endl;
95{0, 10, 15, 20}, {10, 0, 35, 25}, {15, 35, 0, 30}, {20, 25, 30, 0}};
98std::cout <<
"3rd test passed..."<< std::endl;
107std::vector<std::vector<uint32_t>> cities = {
108{0, 5, 10, 15}, {5, 0, 20, 30}, {10, 20, 0, 35}, {15, 30, 35, 0}};
109uint32_t V = cities.size();
int 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4