Sturm's oscillation theorem states that the
n
th eigenfunction of a Sturm–Liouville operator on the interval has
n
−1 zeros (nodes) (Sturm 1836
J. Math. Pures Appl.
1
, 106–186; 373–444). This result was generalized for all metric tree graphs (Pokornyĭ
et al.
1996
Mat. Zametki
60
, 468–470 (
doi:10.1007/BF02320380
); Schapotschnikow 2006
Waves Random Complex Media
16
, 167–178 (
doi:10.1080/1745530600702535
)) and an analogous theorem was proved for discrete tree graphs (Berkolaiko 2007
Commun. Math. Phys.
278
, 803–819 (
doi:10.1007/S00220-007-0391-3
); Dhar & Ramaswamy 1985
Phys. Rev. Lett.
54
, 1346–1349 (
doi:10.1103/PhysRevLett.54.1346
); Fiedler 1975
Czechoslovak Math. J.
25
, 607–618). We prove the converse theorems for both discrete and metric graphs. Namely if for all
n
, the
n
th eigenfunction of the graph has
n
−1 zeros, then the graph is a tree. Our proofs use a recently obtained connection between the graph's nodal count and the magnetic stability of its eigenvalues (Berkolaiko 2013
Anal. PDE
6
, 1213–1233 (
doi:10.2140/apde.2013.6.1213
); Berkolaiko & Weyand 2014
Phil. Trans. R. Soc. A
372
, 20120522 (
doi:10.1098/rsta.2012.0522
); Colin de Verdière 2013
Anal. PDE
6
, 1235–1242 (
doi:10.2140/apde.2013.6.1235
)). In the course of the proof, we show that it is not possible for all (or even almost all, in the metric case) the eigenvalues to exhibit a diamagnetic behaviour. In addition, we develop a notion of ‘discretized’ versions of a metric graph and prove that their nodal counts are related to those of the metric graph.