  We consider the problem of community detection or clustering in the labeled
Stochastic Block Model (LSBM) with a finite number $K$ of clusters of sizes
linearly growing with the global population of items $n$. Every pair of items
is labeled independently at random, and label $\ell$ appears with probability
$p(i,j,\ell)$ between two items in clusters indexed by $i$ and $j$,
respectively. The objective is to reconstruct the clusters from the observation
of these random labels.
  Clustering under the SBM and their extensions has attracted much attention
recently. Most existing work aimed at characterizing the set of parameters such
that it is possible to infer clusters either positively correlated with the
true clusters, or with a vanishing proportion of misclassified items, or
exactly matching the true clusters. We find the set of parameters such that
there exists a clustering algorithm with at most $s$ misclassified items in
average under the general LSBM and for any $s=o(n)$, which solves one open
problem raised in \cite{abbe2015community}. We further develop an algorithm,
based on simple spectral methods, that achieves this fundamental performance
limit within $O(n \mbox{polylog}(n))$ computations and without the a-priori
knowledge of the model parameters.
