Input Matrix of pairwise distances Output Phylogeny Algorithm Repeatedly merge the nearest two clusters. When merging two clusters, the distances of the new cluster are the weighted averages of distances from the two clusters being merged. Complexity \(O(n^3)\) naive, \(O(n^2 \ln n)\) using heap.