  We present an asymptotically exact analysis of the problem of detecting
communities in sparse random networks. Our results are also applicable to
detection of functional modules, partitions, and colorings in noisy planted
models. Using a cavity method analysis, we unveil a phase transition from a
region where the original group assignment is undetectable to one where
detection is possible. In some cases, the detectable region splits into an
algorithmically hard region and an easy one. Our approach naturally translates
into a practical algorithm for detecting modules in sparse networks, and
learning the parameters of the underlying model.
