I have a tree (in the graph theory sense), such as the following example:
This is a directed tree with one starting node (the root) and many ending nodes (the leaves). Each of the edge has a length assigned to it.
My question is, how to find the longest path starting at the root and ending at any of the leaves? The brute-force approach is to check all the root-leaf paths and taking the one with maximal length, but I would prefer a more efficient algorithm if there is one.