Tree diameter

Find the two places with the most roads between them. In a park whose paths form a tree, this gives the longest walk you can take without retracing your steps.

A first wave finds an endpoint of a longest route. Another wave from there finds the opposite end and remembers the path.

Two traversals take O(V) time.