Solution (source code)

= Solution

A <tree> is a connected acyclic graph; acyclic means containing no cycle. Every component of an acyclic graph is a tree. If the component orders are $n_i$, each has $n_i-1$ edges, so with $c\geq1$ components,
$$
\boxed{e(G)=\sum_i(n_i-1)=n-c\leq n-1.}
$$