We analyze the convergence of the spectrum of large random graphs to the spectrum of a limit infinite graph. We apply these results to graphs converging locally to trees and derive a new formula for the Stieltjes transform of the spectral measure of such graphs. We illustrate our results on the uniform regular graphs, Erd¨os-R´enyi graphs and graphs with a given degree sequence. We give examples of application for weighted graphs, bipartite graphs and the uniform spanning tree of n vertices. MSC-class: 05C80, 15A52 (primary), 47A10 (secondary).