comparator for clustering nodes