The following problem popped into my mind all of a sudden and I have no idea how to solve it.
You are given a weighted rooted tree with $$$n$$$ nodes. You need to find the number of unordered pairs of nodes $$$(u,v)$$$ such that
$$$Constraints: 1<=n<= 10^5, -10^6<=edge\,weights<=10^6$$$
It will be really helpful if you can provide me with a solution.