Java Program to Solve Travelling Salesman Problem Using Incremental Insertion Method
Incremental is actually used in software development where the model is designed, implemented, and tested incrementally (a little more is added each time) until the product is finished. It involves both development and maintenance. The product is defined as finished when it satisfies all of its requirements.
Let us briefly discuss the traveling salesman problem. Here we are supposed to find the simplest or shortest distance between all the cities the salesman has to travel i.e., finding the shortest and optimal route between the nodes of the graph. It is also known as TSP and is the most known computer science optimized problem in this modern world.
- Start with a sub-graph consisting of node ‘i’ only.
- Find node r such that cir is minimal and form sub-tour i-r-i.
- (Selection step) Given a sub-tour, find node r not in the sub-tour closest to any node j in the sub-tour; i.e. with minimal crj
- (Insertion step) Find the arc (i, j) in the sub-tour which minimizes cir + crj – cij Insert ‘r’ between ‘i’ and ‘j’.
- If all the nodes are added to the tour, stop. Else go to step 3