The longest path problem in general is NP-hard, but since the graph \(G\)
constructed from the ‘nests-in’ relation is a directed acyclic graph, we may
solve it by solving the shortest path problem of \(-G\).
Other than that, this
problem
is quite straightforward to
solve.