where \(\partial ^{\bf A}_i=\lbrace j:A_{ij}=1\rbrace \)  is the set of the neighbours of \(i\)  and
\(r_{j}^{(i)}({\bf A})\)  is the risk that node \(j\)  causes an outbreak in the `cavity' graph where node \(i\)  is removed. These equations are exact on trees, where loops are
absent, and become exact on locally tree-like graphs, in the limit of large system size, where the typical length of loops diverges logarithmically [1]}.
For a given contact network, one can solve the cavity equations (REF ) and ()
numerically.
Alternatively, in absence of true knowledge of the
contact network one can assume that it is random and use equations (REF ) and () to
derive equations for the global risk
\(g({\bf A})= \frac{1}{N}\sum _{i=1}^N r_{i}({\bf A})\) , which is expected to be self-averaging [2]} when \(N\rightarrow \infty \)  and thus independent of its microscopic details.
Averaging (REF )
over all sites as shown in , one obtains, for a single graph instance \({\bf A}\)
\(\hspace*{-42.67912pt}g({\bf A}) &\hspace*{-4.26773pt}=& \sum _\sigma \sigma \left[\mathrm {P}(\sigma |{\bf A}) - \sum _{k}\mathrm {P}(k,\sigma |{\bf A})\int _{0}^{\infty }t\, \gamma (t) \left(1 - \alpha (t)\hat{g}_{k}({\bf A})\right)^{k}\right] \\\hspace*{-45.52458pt}\hat{g}_{k}({\bf A}) &\hspace*{-5.69046pt}=& \sum _{\sigma ^{\prime }}\sigma ^{\prime }\left[\mathrm {P}(\sigma ^{\prime }|{\bf A}) - \sum _{k^{\prime }\ge 1}\frac{\mathrm {W}(k; k^{\prime },\sigma ^{\prime }|{\bf A})}{\mathrm {W}(k|{\bf A})}\int _{0}^{\infty }t\, \gamma (t) \left(1 - \alpha (t)\hat{g}_{k^{\prime }}({\bf A})\right)^{k^{\prime }-1}\right]\nonumber \) 
