A duality between Schrödinger operators on graphs and certain Jacobi matrices