The expected sum of edge lengths in planar linearizations of trees. Theory and applications