AM_clustering function

Return the clustering matrix