0

Given a graph <V, E>, starting node st, end node ed and certain node set M that must be visited. My question is to find the simple path that visiting all the M. Also I want to know:

1 Is the path exist?

2 If exists, how to find it as fast as possible?

mickeyandkaka
  • 1,452
  • 2
  • 11
  • 21

1 Answers1

1

Because of the set M the problem can be reduced to Hamiltonian path with is known to be NP-Complete.

The way to tell if a path exists is to find one, and to find one the fastest thing is N! in the number of nodes.

What you can do is find fast if a path doesn't exist (disconnected components or critical nodes that need to be passed more than once in order to complete the path) and have some smart heuristics to stop early in the recursion (when it becomes obvious that no path can be completed that way) or pick better node order.

Sorin
  • 11,863
  • 22
  • 26