hierarchical clustering in ruby