Optimal Sampling and Clustering in the Stochastic Block Model