C++ implementation of hierarchical clustering algorithm