  Inhomogeneous random graph models encompass many network models such as
stochastic block models and latent position models. We consider the problem of
statistical estimation of the matrix of connection probabilities based on the
observations of the adjacency matrix of the network. Taking the stochastic
block model as an approximation, we construct estimators of network connection
probabilities -- the ordinary block constant least squares estimator, and its
restricted version. We show that they satisfy oracle inequalities with respect
to the block constant oracle. As a consequence, we derive optimal rates of
estimation of the probability matrix. Our results cover the important setting
of sparse networks. Another consequence consists in establishing upper bounds
on the minimax risks for graphon estimation in the $L\_2$ norm when the
probability matrix is sampled according to a graphon model. These bounds
include an additional term accounting for the "agnostic" error induced by the
variability of the latent unobserved variables of the graphon model. In this
setting, the optimal rates are influenced not only by the bias and variance
components as in usual nonparametric problems but also include the third
component, which is the agnostic error. The results shed light on the
differences between estimation under the empirical loss (the probability matrix
estimation) and under the integrated loss (the graphon estimation).
