Exploiting Phase Transition in Latent Networks for Clustering