Clustering algorithms for PHP