Hierarchical Clustering in Scala