Highlight Longest Path

How to find longest path between two nodes of graph ?

I have taken clues from example (distance) but still not able to to figure out where to make changes to take longest path.

The easy but space-inefficient way is to call collectAllPaths and choose a List that is longest.

It would be better to adapt the code of collectAllPaths to not remember a path if it is shorter than the longest path found so far.

Thanks Walter, You did point me to right direction. I’m working on sol’n right now, once that is done I’ll post the sol’n here