TITLE: Generating function for the number of graphs with $k$ connected components
QUESTION [5 upvotes]: There are $$b_n = \frac{(n-1)!}{2}$$ ways to form a cycle on $n$ labelled vertices, for $n\geq 3$. The exponential generating function for this sequence is
$$ f(x) = \frac{1}{2}\sum_{n\geq 3} (n-1)! \frac{x^n}{n!} =\frac{1}{2}\sum_{n\geq 3} \frac{x^n}{n},$$ 
and if we want the number of graphs on $n$ vertices, the components of which are cycles, the EGF is
$$ g(x) = \exp(f(x)) = \exp \left(\frac{1}{2}\sum_{n\geq 1} \frac{x^n}{n} - \frac{x}{2} - \frac{x^2}{4}\right)$$
$$ =\exp \left( - \frac{x}{2} - \frac{x^2}{4}\right) (1-x)^{-1/2}.$$
(This is example 5.2.8 in Stanley's Enumerative Combinatorics, Vol II)
I'd like to do a similar thing with the number of connected components in a graph.
Fix $n$ and $m$, and consider the graphs on $n$ labelled vertices, with $m$ edges. (We may assume $m\ll n$.) Suppose we know there are $C_{j,l}$ ways to get a connected graph on $j$ vertices and $l$ edges. So, in particular, $C_{j,l}=0$ in case $l<j-1$, or $l>\binom{j}{2}$.
Question: 
Is it feasible to get an EGF for the sequence $a_k$ of the number of graphs with $k$ connected components ? 
Clarification:
Let us use the term $(n,m)$-graph, for a graph with $n$ vertices and $m$ edges. We fix $n$ and $m$, and may assume that $m\ll n$. Now, there are $\binom{\binom{n}{2}}{m}$ such $(n,m)$-graphs. Let $a_k$ be the number of $(n,m)$-graphs with $k$ connected components. Clearly, $\sum_{k=1}^n a_k = \binom{\binom{n}{2}}{m}$. I'm interested in the EGF 
$$ \sum_{k=1}^n \frac{a_k}{k!} x^k.$$

REPLY [7 votes]: We compute  a recurrence  for the  number of  labeled graphs  with $k$
components. With $G(z)$ the EGF of labeled graphs we have
$$G(z) = \sum_{n\ge 0} 2^{n\choose 2} \frac{z^n}{n!}.$$
Here we have included the empty graph  on zero nodes. Now the class of
graphs  $\mathcal{G}$  is in  a  set-of  relationship with  the  class
$\mathcal{C}$ of connected components, namely
$$\def\textsc#1{\dosc#1\csod}
\def\dosc#1#2\csod{{\rm #1{\small #2}}}
\bbox[5px,border:2px solid #00A000]{
\mathcal{G} = \textsc{SET}(\mathcal{C}).}$$
The class of  graphs $\mathcal{C}_k$ with $k$  connected components is
then given by
$$\mathcal{C}_{k} = \textsc{SET}_{=k}(\mathcal{C}).$$
Translating to generating functions we thus have
$$G(z) = \exp C(z)
\quad\text{or}\quad
C(z) = \log G(z)$$
and
$$\bbox[5px,border:2px solid #00A000]{
C_k(z) = \frac{\log^k G(z)}{k!}.}$$
Differentiating (here $k\ge 1$) we have
$$C_k(z)' = C_{k-1}(z) \frac{G'(z)}{G(z)}
\quad\text{or}\quad
C_k(z)' G(z)  = C_{k-1}(z) G'(z).$$
Writing $$C_k(z) = \sum_{n\ge 0} C_{n,k} \frac{z^n}{n!}$$
and extracting coefficients we have
$$[z^{n-1}] C_k(z)' G(z) = [z^{n-1}] C_{k-1}(z) G'(z)$$
which is
$$\sum_{q=0}^{n-1} C_{q+1, k} \frac{1}{q!}
2^{n-1-q\choose 2} \frac{1}{(n-1-q)!}
= \sum_{q=0}^{n-1} C_{q, k-1} \frac{1}{q!}
2^{n-q\choose 2} \frac{1}{(n-1-q)!}.$$ 
or
$$\sum_{q=0}^{n-1}  {n-1\choose q} C_{q+1, k}
2^{n-1-q\choose 2}
= \sum_{q=0}^{n-1} {n-1\choose q} C_{q, k-1} 
2^{n-q\choose 2}.$$ 
This yields the recurrence
$$\bbox[5px,border:2px solid #00A000]{
C_{n, k} = \sum_{q=0}^{n-1} {n-1\choose q} C_{q, k-1} 
2^{n-q\choose 2}
- \sum_{q=0}^{n-2}  {n-1\choose q} C_{q+1, k}
2^{n-1-q\choose 2}.}$$
The base case is that when $k=0$ and $n=0$ we get the empty graph,
when $k=0$ or $n=0$ but not both we have zero. This yields
for one component the sequence
$$1, 1, 4, 38, 728, 26704, 1866256, 251548592, 
\\ 66296291072, 34496488594816, 35641657548953344, 
\\ 73354596206766622208, 301272202649664088951808, \ldots $$
which  points to  OEIS  A001187 where  the
data are confirmed. Listing the $C_{n,k}$ in order with increasing $k$
for fixed $n$ and increasing $n$ (triangular array) we find
$$1, 1, 1, 4, 3, 1, 38, 19, 6, 1, 728, 230, 55, 10, 1, 26704,
\\ 5098, 825, 125, 15, 1, 1866256, 207536, 20818, 2275, 245, 
\\ 21, 1, 251548592, 15891372, 925036, 64673, 5320, 434, 28, 1,
\ldots $$
which points to OEIS  A143543, where we get
confirmation once more. The reader  who wants to experiment with these
exponential generating  functions is invited to  consult the following
Maple code.

CGF :=
proc(n, k)
option remember;
local G;

    G := add(2^binomial(q,2)*z^q/q!, q=0..n);
    n!*coeftayl(log(G)^k/k!, z=0, n);
end;

C :=
proc(n, k)
option remember;

    if k = 0 and n = 0 then return 1 fi;
    if k = 0 or n = 0 then return 0 fi;

    add(binomial(n-1,q)*C(q,k-1)*2^binomial(n-q,2),
        q=0..n-1)
    - add(binomial(n-1,q)*C(q+1,k)*2^binomial(n-1-q,2),
          q=0..n-2);
end;

OEIS := mx -> seq(seq(C(n,k), k=1..n), n=1..mx);

As a  sanity check  when we compute  $\sum_{k=1}^n C_{n,k}$  using the
values from the recurrence we really do obtain $2^{n\choose 2}.$