Ruby hierarchical agglomerative clustering algorithm