Question: implement the program in plain C/C++ For this exercise you are asked to solve the Traveling Salesman Problem: given a complete, undirected weighted graph of

 implement the program in plain C/C++ For this exercise you are

implement the program in plain C/C++

For this exercise you are asked to solve the "Traveling Salesman Problem": given a complete, undirected weighted graph of N>2 vertices you have to find the minimum Hamiltonian cycle. A Hamiltonian cycle is a cycle that visits all vertices exactly once (with the exception of the first and last vertex). You can assume that the weights are positive, but you cannot assume that the weights obey the triangle inequality Specifications The input is specified in a file whose name is the first argument of the program. The first line contains an integer M specifying how many datasets are in the file. The reminder of the file encodes the datasets. Each dataset consists of a definition of a graph as follows: It starts with two space separated positive integers V and E on the first line that indicates the number of vertices and edges respectively. The following lines specify the weights on the edges of the graph as following: each edge is specified on one line as 3 numbers: uvw. u is the index of the first vertex, v is the index of the second vertex and w is a positive integer weight of the edge (u,v). Note that all edges of the graph appear in this list exactly once. (i.e. if we have an entry for (u,v) we will not have one for (v, Here is an example: 011 02 1 12 1 4 6 012 02 1 03 2 122 13 1 23 2 The output is a file whose name is the second argument of the program. Each line encodes the results of each test case. The algorithm should output the length of the minimal Hamiltonian cycle For example, the output corresponding to the input above is as follows 6 For this exercise you are asked to solve the "Traveling Salesman Problem": given a complete, undirected weighted graph of N>2 vertices you have to find the minimum Hamiltonian cycle. A Hamiltonian cycle is a cycle that visits all vertices exactly once (with the exception of the first and last vertex). You can assume that the weights are positive, but you cannot assume that the weights obey the triangle inequality Specifications The input is specified in a file whose name is the first argument of the program. The first line contains an integer M specifying how many datasets are in the file. The reminder of the file encodes the datasets. Each dataset consists of a definition of a graph as follows: It starts with two space separated positive integers V and E on the first line that indicates the number of vertices and edges respectively. The following lines specify the weights on the edges of the graph as following: each edge is specified on one line as 3 numbers: uvw. u is the index of the first vertex, v is the index of the second vertex and w is a positive integer weight of the edge (u,v). Note that all edges of the graph appear in this list exactly once. (i.e. if we have an entry for (u,v) we will not have one for (v, Here is an example: 011 02 1 12 1 4 6 012 02 1 03 2 122 13 1 23 2 The output is a file whose name is the second argument of the program. Each line encodes the results of each test case. The algorithm should output the length of the minimal Hamiltonian cycle For example, the output corresponding to the input above is as follows 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!