The inverse problem for the Sturm-Liouville operator on a graph is considered. We suppose that the graph is a tree (i.e., it does not contain cycles), and on each edge the Schr\"odinger equation (with a variable potential) is defined. The Weyl matrix function is introduced through all but one boundary vertices. We prove that, the Weyl matrix function uniquely determines the graph (its connectivity and the lengths of the edges together with potentials on them). If the connectivity of the graph is known, the lengths of the edges and potentials on them are uniquely determined by the diagonal terms of either the Weyl matrix function, the response operator or by the back scattering coefficients.