0

I'm looking for advice or resources to solve a problem similar to TSP but where:

  • forks are allowed, ie. the salesman can duplicate himself on each city;
  • starting and ending locations doesn't matter and can be different.

This means, given these cities (where x are cities and visual space between each x are proportional to distances between cities):

x

  x x

x 

A regular-TSP solution could be:

x
|\
| x-x
|  /
x-/ 

But I would like this kind of solution, which is better according to the new rules:

x
 \ 
  x-x
 /
x 

Does this problem have a name and are there some publication about an optimized solution?

roipoussiere
  • 5,142
  • 3
  • 28
  • 37
  • 1
    It sounds like you are just describing the minimum spanning tree problem? Or maybe the Steiner tree problem? – LarrySnyder610 Jun 04 '19 at 01:18
  • Thank you, indeed it was the minimum spanning tree problem! Can you add this as an answer? – roipoussiere Jun 04 '19 at 08:30
  • By the way, which algorithm is adapted for small graphs (less than 30 nodes), where a very good optimization is not necessary, but a fast processing time is required? Prism (https://en.wikipedia.org/wiki/Prim%27s_algorithm)? – roipoussiere Jun 04 '19 at 08:51

2 Answers2

1

You are describing the minimum spanning tree (MST) problem. You got lucky! Because while TSP is NP-hard, the MST is among the easiest combinatorial optimization problems to solve, computationally. It can be solved in O(m log n) time through a straightforward implementation of either Prim's or Kruskal's algorithm (and, both of those algorithms are also pretty easy to code). There are also other algorithms and other data structures that can make the complexity even lower, but if you have 30 nodes, either of these algorithms will solve it in a fraction of a second.

LarrySnyder610
  • 2,277
  • 12
  • 24
  • "if you have 30 nodes, either of these algorithms will solve it in a fraction of a second" yes, but I have many of these small MST problems to solve, so time matters. But anyway, I chose Prism. ;) – roipoussiere Jun 05 '19 at 08:33
0

I'm not sure what the goal is here, but it sounds like a problem for A* search algorithm.

Edwin
  • 33
  • 6
  • Thank you. From what I understand, A* search algorithm is used to search one path between 2 points. Here there is many points with many paths. – roipoussiere Jun 03 '19 at 15:00