# Unweighted UniFrac algorithm

Formally, the measure is calculated using the following formula, where $N$ is the number of nodes in the tree, $l_i$ is the branch length between node $i$ and its parent, and $A_i$ and $B_i$ are indicators equal to 0 or 1 as descendants of node $i$ are absent or present in communities A and B respectively.
$u = \frac{\sum_{i=1}^{N} l_i | A_i - B_i |} {\sum_{i=1}^{N} l_i \max(A_i, B_i)}$