1

I have an adjacency matrix describing an undirected graph and I need to find all possible paths that pass through each and every node once.

My graph has 25 nodes, therefore any path with length < 25 should be discarded.

I'd prefer the input to be and adjacency matrix rather than typing out each connection (the matrix is quite big).

I tried looking into DFS algorithms but they often require a start and end node or will display all the paths inline without showing each individual path. I need my algorithm to look through every possible path, starting from any node and ending wherever it can.

If you have any idea of how I can start this project it'd be greatly appreciated.

I'm cool with C++, Java, js, or Python. Thank you!

  • Does this answer your question? [Enumerating all hamiltonian paths](https://stackoverflow.com/questions/5766160/enumerate-all-hamiltonian-paths) – kcsquared Oct 17 '21 at 23:07
  • You can search for all possible paths **between 2 nodes** as described in the question lined in the previous comment. Here is a small runnable [example](https://stackoverflow.com/a/48718818/3992939). You'll have to repeat it for every 2-node combination. – c0der Oct 18 '21 at 06:34

0 Answers0