TITLE: How many connected graphs over V vertices and E edges?
QUESTION [30 upvotes]: Is there a way to calculate the number of simple connected graphs possible over given edges and vertices? 
Eg: 3 vertices and 2 edges will have 3 connected graphs
But 3 vertices and 3 edges will have 1 connected graph
Then 4 edges and 3 will have 4 connected graphs
Till such values...it is easy to see its
V choose E
But what about when the number of vertices are less than number of edges...how to calculate then?
I am not able to visualize that
Can it be a variation of the Stars and Bars problem
Like...number of ways 7 edges(balls) can be connected to (kept in) 5 vertices(bags) such that no vertex(bag) is isolated (is empty)
Here maybe we might have to consider the number of edges twice as each edge needs two vertices...

REPLY [6 votes]: Here is my attempt at a Python implementation (2 or 3) of gf3 and gf5. I am only using builtin libraries, so hopefully that will encourage others to play with this. My results agree with the above for $1\leq n \leq30$ and $n=50$ but this will obviously need verification.
The performance of gf5 is not great, over 400 seconds for $g_{55}(u)$ alone. I experimented with a few different external math libraries for calculating the binomial coefficients more quickly, but they actually had surprisingly little effect. I have written the code in such a way that it's easy to substitute but still take advantage of memoization. Perhaps the interested reader could find something better?
gf3, on the other hand, performs as expected. It finished $1\leq n \leq 542$ in 34 seconds. The output is rather cumbersome, but can be viewed here.
from __future__ import division, print_function

from math import factorial
binomial_coefficient_cache = dict()
qq_cache = dict()


def binomial_coefficient_naive(n, k):
    d = n - k
    if d < 0:
        return 0
    return factorial(n) // factorial(k) // factorial(d)
current_binomial = binomial_coefficient_naive


def binomial_memoized(n, k):
    if (n, k) in binomial_coefficient_cache:
        return binomial_coefficient_cache[n, k]
    res = current_binomial(n, k)
    binomial_coefficient_cache[n, k] = res
    return res
binomial = binomial_memoized


def qq(n, k):
    '''Number of labeled, simply connected Graphs of order n, size k '''
    if (n, k) in qq_cache:
        return qq_cache[n, k]
    s = n * (n - 1) // 2
    if k < n - 1 or k > s:
        res = 0
    elif k == n - 1:
        res = int(pow(n, (n - 2)))
    else:
        res = binomial(s, k)
        for m in range(0, n - 1):
            res1 = 0
            lb = max(0, k - (m + 1) * m // 2)
            for p in range(lb, k - m + 1):
                np = (n - 1 - m) * (n - 2 - m) // 2
                res1 += binomial(np, p) * qq(m + 1, k - p)

            res -= binomial(n - 1, m) * res1

    qq_cache[n, k] = res
    return res


def gf5(n):
    '''Number of labeled, simply connected Graphs of order n'''
    ub = (n * (n - 1)) // 2
    qn = sum([qq(n, k) for k in range(n - 1, ub + 1)])
    return(qn)

gf3_cache = dict()
B_cache = dict()


def B(m):
    if m in B_cache:
        return B_cache[m]
    B_cache[m] = int(pow(2, m * (m - 1) // 2)) if m >= 2 else 1
    return B_cache[m]


def gf3(n):
    '''Number of labeled, simply connected Graphs of order n, computed very quickly'''
    if n in gf3_cache:
        return gf3_cache[n]
    if n < 2:
        s = 1
    else:
        q = n - 1
        s = B(q + 1) - sum(binomial(q, m) * B(q - m) * gf3(m + 1)
                           for m in range(q))
    gf3_cache[n] = s
    return s

Any suggestions would be much appreciated, this math is quite a bit over my head ;)