  Estimating the number of communities is one of the fundamental problems in
community detection. We re-examine the Bayesian paradigm for stochastic block
models and propose a "corrected Bayesian information criterion",to determine
the number of communities and show that the proposed estimator is consistent
under mild conditions. The proposed criterion improves those used in Wang and
Bickel (2016) and Saldana et al. (2017) which tend to underestimate and
overestimate the number of communities, respectively. Along the way, we
establish the Wilks theorem for stochastic block models. Moreover, we show
that, to obtain the consistency of model selection for stochastic block models,
we need a so-called "consistency condition". We also provide sufficient
conditions for both homogenous networks and non-homogenous networks. The
results are further extended to degree corrected stochastic block models.
Numerical studies demonstrate our theoretical results.
