Question: This part contributes to module outcomes 1 and 2 . The TSP will be implemented as follows: suppose there are n cities. You will create

This part contributes to module outcomes 1 and 2.
The TSP will be implemented as follows: suppose there are n cities. You will create an n-by-n matrix M, with one row and one column per city. M(i,j) gives the cost of going from city i to city j. If there is a road from i to j then M(i,j) is a positive integer, otherwise it is -1 by convention. We assume all roads are bi-directional so M is symmetric. A tour is a path that starts at city 1, visits every other city once, and ends back at city 1. A minimal tour is one with minimum cost (where the cost of a tour is the sum of the costs of the roads that constitute it). Note there may be more than one minimal tour.
The TSP asks that we find a minimal tour.
d) Given a tour generated from matrix M, how do you compute its cost? (If this question feels easy, it is)
e) Just in case your algorithm gets a matrix M that does not contain any tours (e.g., it is not possible to come back to the starting city 1), it's a good idea to be able to detect that and output some message like "This matrix does not contain any tours" before you attempt to find non-existent tours. How do you detect that?

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 Programming Questions!