  To unravel the driving patterns of networks, the most popular models rely on
community detection algorithms. However, these approaches are generally unable
to reproduce the structural features of the network. Therefore, attempts are
always made to develop models that incorporate these network properties beside
the community structure. In this work, we present a probabilistic generative
model and an efficient algorithm to both perform community detection and
capture reciprocity in networks. Our approach jointly models pairs of edges
with exact 2-edge joint distributions. In addition, it provides closed-form
analytical expressions for both marginal and conditional distributions. We
validate our model on synthetic data in recovering communities, edge prediction
tasks, and generating synthetic networks that replicate the reciprocity values
observed in real networks. We also highlight these findings on two real
datasets that are relevant for social scientists and behavioral ecologists. Our
method overcomes the limitations of both standard algorithms and recent models
that incorporate reciprocity through a pseudo-likelihood approximation. The
inference of the model parameters is implemented by the efficient and scalable
expectation-maximization algorithm, as it exploits the sparsity of the dataset.
We provide an open-source implementation of the code online.
