I have an SCC of a directed graph. I want to find a path that visits every vertex in this SCC at least once, starting from a vertex s. I know this may be an NP problem. Regardless, how do I solve this?
Asked
Active
Viewed 913 times
1
-
A Hamiltonian path (https://en.wikipedia.org/wiki/Hamiltonian_path) visits each vertex *exactly* once, and determining if one exists is NPC. However, visiting *at least* once seems easier - except that it might not be a path any longer... – gilleain Nov 08 '17 at 11:41
-
1If you need _any_ path (not necessary simple), then you may find _some_ path from 1 to 2, then _some_ path from 2 to 3, so on (1, 2, 3, ... are the numbers of vertices in your SCC). And if you need the simple path then @gilleain correctly noticed that this is an NP-complete Hamiltonian path problem. – Ivan Smirnov Nov 08 '17 at 15:05
-
@IvanSmirnov Thanks! I needed some path(walk) ; not a simple path. This helped. – Amitesh Srivastava Nov 11 '17 at 06:33
-
@AmiteshSrivastava Great! I added my comment as an answer so you could formally accept it. – Ivan Smirnov Nov 11 '17 at 14:46
1 Answers
0
If you need any path (not necessary simple), then you may find some path from 1 to 2, then some path from 2 to 3, so on (1, 2, 3, ... are the numbers of vertices in your SCC). And if you need the simple path then gilleain correctly noticed in comments that this is an NP-complete Hamiltonian path problem.

Ivan Smirnov
- 4,365
- 19
- 30