I would like to know if there is a function in NetworkX to solve the TSP? I can not find it. Am I missing something? I know it's an NP hard problem but there should be some approximate solutions right?
The traveling salesman problem (TSP) is an algorithmic problem tasked with finding the shortest route between a set of points and locations that must be visited. In the problem statement, the points are the cities a salesperson might visit.
This means that TSP is classified as NP-hard because it has no “quick” solution and the complexity of calculating the best route will increase when you add more destinations to the problem. The problem can be solved by analyzing every round-trip route to determine the shortest one.
MST is a relaxed problem of TSP, So you can use MST solution as a heuristic function for TSP, Because It always estimate a solution with less cost than real solution. Your question's answer is "no". you can't use MST solutions for TSP.
The travelling salesman problem (also called the travelling salesperson problem or TSP) asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?" It is an NP-hard problem in ...
Networkx provides an approximate solution to TSP, see page. Their solution is based on writting TSP as Quadratic Unconstrained Binary Optimization (QUBO) problem.
Note that it is proven that finding an alpha-approximation to TSP is proven to be NP-hard in general. So you can't have a guarantee on the quality the obtained result. Howver there is a particular case, Euclidean-TSP, where we can construct 2-approximation and even 1.5-approximation of TSP, using Christofides algorithm however I was not able to find the implementation of this algorithm in Networkx.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With