1

I have an undirected graph and i'd like to find all the possible paths in it connecting all the nodes of a given set. Is it an NP problem? Is there an algorithm to doing it, or a good way to accomplish it? I don't care about the order by which each paths touches the nodes in the set, i just need it to go through each of them.

1 Answers1

0

It's called Hamiltonian Path Problem and it is NP-complete.

For detailed info: https://en.wikipedia.org/wiki/Hamiltonian_path_problem

Safak Ozdek
  • 906
  • 11
  • 18
  • At first, as you, I had thought about the Hamiltonian Path problem, but it doesn't fit exactly with my scenario, or at least I can't see how it could, the graph has other nodes and not just those in the given set: i want each paths touching all of them but i am also interested in those nodes in the graph which are traversed by the path and which are not in the set. – Alessandro Oddi Nov 16 '17 at 11:09
  • @AlessandroOddi In worst case, your set includes all nodes in the graph, so it is upper bounded by Hamiltonian Path Problem, if Hamiltonian Path Problem is NP-complete, then your problem is also NP-complete. – Safak Ozdek Mar 04 '20 at 12:41