I am trying to come up with java code for the traveling salesmanproblem. My guidelines are, I start at city 0 in a given symmetricmatrix, I must go to each city only once, and end up back at thestarting city 0. I must output the cost as well as the path itwent.
I have obtained the correct cost, but I am having troubleoutputting the correct path.
This is my code:
package exacttsp;
import java.io.File;
import java.io.FileNotFoundException;
import static java.lang.Integer.MAX_VALUE;
import java.util.Arrays;
import java.util.Scanner;
class ExactTSP {
public static int Cost(int matrix[][], int index, int dim){
int[] array = new int[dim];
int[] bestPath = new int[dim];
for (int i = 0; i < dim;
OR
OR