Write a function that takes a cost matrix and uses the Minimum Spanning (Matching Approach) algorithm to produce a Travelling Salesman Problem solution. This function should output the TSP final tour as well as the cost of the tour. Comment your code appropriately to show an understanding of logic as well as the procedure. Demonstrate the performance of your code using CostMat.
CostMat = [[0,6,8,6,7,3,5,2,3,2,5,5,4,4,5,8,7],[6,0,6,3,2,5,7,4,7,8,11,7,6,8,11,10,13],[8,6,0,9,8,5,3,8,5,8,5,13,12,12,9, 16,9],[6,3,9,0,1,6,8,5,8,9,12,6,7,9,12,7,15],[7,2,8,1,0,5,7,4,7,8,11,5,6,8,11,8,13],[3,5,5,6,5,0,2,3,2,3,6,8,7, 9,6,11,8],[5,7,3,8,7,2,0,7,2,5,4,12,9,9,6,13,6],[2,4,8,5,4,3,7,0,3,4,7,5,4,4,7,8,9],[3,7,5,8,7,2,2,3,0,3,4,10,7, 7,4,11,6],[2,8,8,9,8,3,5,4,3,0,3,5,4,4,3,8,5],[5,11,5,12,11,6,4,7,4,3,0,10,7,7,4,11,4],[5,7,13,6,5,8,12,5,10,5 ,10,0,1,3,8,3,8],[4,6,12,7,6,7,9,4,7,4,7,1,0,2,5,4,7],[4,8,12,9,8,9,9,4,7,4,7,3,2,0,3,4,5],[5,11,9,12,11,6,6,7, 4,3,4,8,5,3,0,7,2],[8,10,16,7,8,11,13,8,11,8,11,3,4,4,7,0,7],[7,13,9,15,13,8,6,9,6,5,4,8,7,5,2,7,0]] Please provide steps in logic thank you tutor
Subject: Python
Step by step
Solved in 2 steps