Finding the longest path in a graph is itself a pretty well-described NP-complete problem: https://en.wikipedia.org/wiki/Longest_path_problem
Alternately, you can listen to a Billy Joel parody that describes the problem in decidedly less academic terms: https://www.youtube.com/watch?v=a3ww0gwEszo