I want to find the longest path distance on a cactus graph with certain restricting directed paths.
For example, if we have following 4 nodes,
This would mean that
- if we visit 1, we cannot go to 2 anymore
That is, 1 → 2 and 1 → 3 → 2 are not allowed. However, 2 → 1 is allowed.
Likewise
cannot travel from 2 to 3
cannot travel from 3 to 1
cannot travel from 1 to 0
can travel any others
So we have the probable paths (1, 3, 2), (0, 2, 1), and so on. Therefore the longest distance is 3, and we never get 4.
In this case, the answer is 9. (4, 5, 6, 7, 8, 0, 9, 2, 3), etc...
I’m stuck on this problem one week. Still, I have no idea how to approach. Thanks.