Commit 18a8cd8
committed
Replace Hierarchical's round-based merge with nearest-neighbor chain
The round-based merge assumes O(log n) rounds, but once few enough clades
remain the nearest-neighbor graph forms chains rather than isolated mutual
pairs, so it degrades to one merge per round while each round still scans
the whole matrix. That is O(n) rounds at O(n^2) each.
Use the nearest-neighbor-chain algorithm instead, which SciPy uses for this
same family of Lance-Williams-updatable linkages.
Also sort each clades row after remapping ids: the remapping is a permutation
and does not preserve order when two merges tie, which could leave a row
descending.1 parent b4ed6f0 commit 18a8cd8
2 files changed
Lines changed: 276 additions & 122 deletions
0 commit comments