Spectral analysis of random graphs with application to clustering and sampling