We compute the generating functions of a O(n) model (loop gas model) on a random lattice of any topology. On the disc and the cylinder, they were already known, and here we compute all the other topologies. We find that the generating functions (and
the correlation functions of the lattice) obey the topological recursion, as usual in matrix models, i.e they are given by the symplectic invariants of their spectral curve.
We introduce a new matrix model representation for the generating function of simple Hurwitz numbers. We calculate the spectral curve of the model and the associated symplectic invariants developed in [Eynard-Orantin]. As an application, we prove the
conjecture proposed by Bouchard and Marino, relating Hurwitz numbers to the spectral invariants of the Lambert curve exp(x)=y exp(-y).