  A method is introduced for studying large deviations in the context of
statistical physics of disordered systems. The approach, based on an extension
of the cavity method to atypical realizations of the quenched disorder, allows
us to compute exponentially small probabilities (rate functions) over different
classes of random graphs. It is illustrated with two combinatorial optimization
problems, the vertex-cover and coloring problems, for which the presence of
replica symmetry breaking phases is taken into account. Applications include
the analysis of models on adaptive graph structures.
