I am trying to solve a modified version of the TSP. In my version, multiple visits to a city are allowed, as long as the path is the shortest, and also, only subset of the cities are compulsory to visit, as in, you can go through other cities to visit all the subset cities if path is shorter, but if not, the other cities can be ignored. NetworkX has approx. solution for the traditional TSP using the dwave_networkx.algorithms.tsp.traveling_salesperson
, but I have trouble solving this one. A naive approach can be to find all possible combinations of the subset cities and check which has the shortest total path length, but that solution will have a n^2 complexity for trying each combination, plus the complexity for finding shortest path for each two cities. So, what should I use to solve this problem using NetworkX.
Asked
Active
Viewed 989 times
0

petezurich
- 9,280
- 9
- 43
- 57

Shantanu Shinde
- 932
- 3
- 23
- 48
1 Answers
0
You can select a path randomly and optimize the way on it. Basically, randomly assign a way between two nodes. Than on nodes, try to find optimal way for n+2 nodes. A --> B --> C if there is a path between shortest then try A--> D --> C---E if there is path between D and E shortest than D --> K --> E then again iterate A--> D --> F --> E simply that sound to me a good idea. I don't have proof now but it can give you the possible shortest path. I hope that will be helpful. Good luck.

Barış Can Tayiz
- 87
- 5