I recently saw a problem in some online judge where I was given a tree and was asked the value of Σ f(u, v) for all pair of u, v
where f is some function that takes two nodes u, v of a graph. for example f(u, v) can be any of these.
1) f(u, v) = distance between u, v in a weighted tree.
2) If every nodes have number written, f(u, v) can be median / mode / average/ sum of all numbers in path from u to v.
3) if every nodes have colors assigned f(u, v) can be number of distinct colors between path from u to v.