Bayesian nonparametric clustering as a community detection problem