Im implementing 2 algorithms for the TSP which uses a class which includes the routes, their cost, etc. At the minute it uses random values which is fine, although I now need to compare the algorithms so to make this fair I need to make the inputs the same (which is obviously unlikely to happen when using random inputs!) The issue im having is I dont know how to change it from random values to inserting pre-determined values into the 2D array, not just that but I also dont know how to calculate the costs of these values.
Randomly generates node values:
Random rand = new Random();
for (int i=0; i<nodes; i++) {
for (int j=i; j<nodes; j++) {
if (i == j)
Matrix[i][j] = 0;
else {
Matrix[i][j] = rand.nextInt(max_distance);
Matrix[j][i] = Matrix[i][j];
}
}
}
Im assuming for the above a declare a matrix of say [4][4] and then int matrix [][] = insert values ?
I do not help with some other sections of this class but I think I need to make sure this part is right before asking anymore!
Thanks a lot in advance!