Initially invented to deal with the Sherrington–Kirkpatrick model of spin glasses, the cavity method has shown wider applicability. It can be regarded as a generalization of the Bethe – Peierls iterative method in tree-like graphs, to the case of a graph with loops that are not too short. The cavity method can solve many problems also solvable using the replica trick but has the advantage of being more intuitive and less mathematically subtle than replica-based methods.