Let c denote the number of connected components of G. We want to show that c = 1.
Number the components of G from 1 \dots c, and say that component i has n_i vertices. Then \sum _{i=1}^c n_i = n, because adding up the number of vertices in each component gives the total number of vertices. Each connected component is by definition a connected graph; each component must also be acyclic since we assumed that G is acyclic. Hence we may apply Connected, acyclic graphs have n-1 edges to conclude that component i has n_i - 1 edges. Adding these up, the total number of edges in G is |E| = \sum _{i=1}^c (n_i - 1) = \left (\sum _{i=1}^c n_i \right ) - \left (\sum _{i=1}^c 1 \right ) = n - c. But we already assumed the number of edges in G is n-1, and hence c = 1 as desired.