Traveling salesman problem
This is the problem:
A student is employed as a courier in a firm with n points where he has to deliver products on time.
The salary of the courier is fixed and does not depend on the length of the journey. To estimate the total cost of the journeys. The task is to find the following travel route,
which passes through each point only once and whose total cost of travelling around the points is the lowest,
i.e. so that the student makes more profit. The starting and end point of the student's journey is always the first point.
The data is written in the text file 'U3.txt'. The first line of the file is an integer n (5 ≤ n ≤
50), indicating the size of the square matrix. The following lines contain the matrix K(n,n), which lists
the cost of travel between individual points, where K[i,j]=K[j,i] and represents the cost of travel between points i and j. Derive
the results listing the points in the order in which they were visited and the cost of the journey.
Data:
5
0 1 3 4 2
1 0 4 2 6
3 4 0 7 1
4 2 7 0 7
2 6 1 7 0
Results:
1, 5, 3, 2, 4, 1 = 13
Code is in the pictures attached, over the char limit for the message.
The code outputs these results:
Minimum cost: 13
Path: 5 -> 4 -> 3 -> 2 -> 1 -> 1
How do i need to alter the code so that it outputs the results in this state: 1, 5, 3, 2, 4, 1