The stability method is very useful for obtaining exact solutions of many extremal graph problems. Its key step is to establish the stability property which, roughly speaking, states that any two almost optimal graphs of the same order $n$ can be made isomorphic by changing o(n^2) edges. Here we show how the recently developed theory of graph limits can be used to give an analytic approach to stability. As an application, we present a new proof of the Erdos-Simonovits Stability Theorem. Also, we investigate various properties of the edit distance. In particular, we show that the combinatorial and fraction