General formulation and evaluation of agglomerative clustering methods with metric and non-metric distances