Add hierarchical clustering functionality and unit tests.