  What does an Erdos-Renyi graph look like when a rare event happens? This
paper answers this question when p is fixed and n tends to infinity by
establishing a large deviation principle under an appropriate topology. The
formulation and proof of the main result uses the recent development of the
theory of graph limits by Lovasz and coauthors and Szemeredi's regularity lemma
from graph theory. As a basic application of the general principle, we work out
large deviations for the number of triangles in G(n,p). Surprisingly, even this
simple example yields an interesting double phase transition.
