# Given a binary tree of leaves with weights, find minimum weights for internal nodes (such that sum(weighti-weightj) is minimized for (i,j)∈E(T))

So this is a question within a bigger question for which I've reduced to this so far:

If I have a tree (phylogenetic) with known weights for leaves, how would I find the weights for all internal nodes such that the sum of the differences between the weights of two endpoints of edges is minimized?

• I.e. Given a tree $$T$$ with $$n$$ leaves with weights $$D_1,\ldots,D_n$$ respectively. Assign;

a weight $$D_u$$ to each internal node $$u = n+1,\ldots,2n-1$$ such that $$\sum_{(u,v) \in E(T)} (D_u-D_v)$$ is minimized.

If it helps, it might be similar to the Sankoff algorithm or so. Thanks!

• You can use LaTeX to typeset mathematics, rather than doing it manually with various tricks (and non-tricks). A couple of users have edited to show you how; we also have a brief tutorial – Apass.Jack Oct 23 '18 at 14:33
• Do you mean the absolute value of the difference between $D_u$ and $D_v$ , $|D_u-D_v|$ instead of $D_u-D_v$? Minimizing (the sum of) the difference does not make sense, since $(v,u)$ is the same edge as $(u,v)$. – Apass.Jack Oct 23 '18 at 15:01