  Message passing equations yield a sharp percolation transition in finite
graphs, as an artifact of the locally treelike approximation. For an arbitrary
finite, connected, undirected graph we construct an infinite tree having the
same local structural properties as this finite graph, when observed by a
nonbacktracking walker. Formally excluding the boundary, this infinite tree is
a generalization of the Bethe lattice. We indicate an infinite, locally
treelike, random network whose local structure is exactly given by this
infinite tree. Message passing equations for various cooperative models on this
construction are the same as for the original finite graph, but here they
provide the exact solutions of the corresponding cooperative problems. These
solutions are good approximations to observables for the models on the original
graph when it is sufficiently large and not strongly correlated. We show how to
express these solutions in the critical region in terms of the principal
eigenvector components of the nonbacktracking matrix. As representative
examples we formulate the problems of the random and optimal destruction of a
connected graph in terms of our construction, the nonbacktracking expansion. We
analyze the limitations and the accuracy of the message passing algorithms for
different classes of networks and compare the complexity of the message passing
calculations to that of direct numerical simulations. Notably, in a range of
important cases, simulations turn out to be more efficient computationally than
the message passing.
