  We present an analytical approach to calculating the distribution of shortest
paths lengths (also called intervertex distances, or geodesic paths) between
nodes in unweighted undirected networks. We obtain very accurate results for
synthetic random networks with specified degree distribution (the so-called
configuration model networks). Our method allows us to accurately predict the
distribution of shortest path lengths on real-world networks using their degree
distribution, or joint degree-degree distribution. Compared to some other
methods, our approach is simpler and yields more accurate results. In order to
obtain the analytical results, we use the analogy between an infection reaching
a node in $n$ discrete time steps (i.e., as in the susceptible-infected
epidemic model) and that node being at a distance $n$ from the source of the
infection.
