
To count the quartets induced by T with 0 and 17 as siblings, we consider the path between them (shown in blue in panel A). The deletion of the path produces six rooted subtrees (highlighted in gray). Because 0 and 17 are siblings in a quartet
if and only if the other two taxa are drawn from the same subtree, the number of bad edges can be computed as
. Here we show how to compute the number of quartets induced by T with 0 and 17 as siblings after rooting T arbitrarily. Panel B shows that we need to consider the number of ways of selecting two taxa from the same subtree for three cases: (1) the subtree
above the lca(0, 17) (highlighted in green), (2) all subtrees off the path from the lca(0, 17) to the left taxon 0 (highlighted in red), and (3) all subtrees off the path from the lca(0, 17) to the right taxon 17 (highlighted in pink). Case 1 can be computed in constant time if we know the number of leaves
below the LCA, that is, A[0, 17] = 6 (Eq. 8). Cases 2 and 3 can also be computed in constant time as follows. Panel C shows the prefix of the left child of the lca(0, 17), denoted p[lca(0, 17).left]. This quantity is the number of ways of selecting two taxa from the same subtree for all subtrees off the path from the
root to this vertex (circled in red). Similarly, the prefix of taxon 0, denoted p[0], is the number of ways of selecting two taxa from the same subtree for all subtrees off the path from the root to 0 (circled
in purple). Therefore, the number of ways of selecting two taxa from all subtrees in case 2 (i.e., subtrees highlighted in
red in B) is L[0, 17] = p[0] − p[lca(0, 17).left] = 7 (Eq. 9). Case 3 can be computed in a similar fashion as R[0, 17] = p[17] − p[lca(0, 17).right] = 3 (Eq. 10). Putting this all together gives B[0, 17] = 16 (Eq. 6).











