It is hard to find the maximum path in a graph with cycles. Bypass in width - in general in any way. Brute-force only (which is more of a recursive depth-first search, but with backtracking).
If the graph is a tree or directed acyclic, then any traversal works.