I am looking for a way of expressing the number of connected labelled undirected graphs given the amount of vertices and edges. There is already quite a lot on the subject on this site, which made me find Marko Riedel's answer here: How many connected graphs over V vertices and E edges? (especially the recursive one in the definitely last addendum). Yet I haven't been able to make the formula work for $n \geq 12$. When implementing the code in Python3 , for n=12, I find $73354596206766620926$ as sum on $k$, whereas according to Harary and Palmer formula, result should be $73354596206766622208$ (which is 1282 bigger).
Firstly, I would like to know if failed the implementation or if his development contains a mistake (which I highly doubt due to the difference of level between the two of us...)
Yet, I decided to keep the same reasoning as he did, with the generating function and the fact that:
$$q_{n,k} = n![u^k][z^n]\sum_{q=1}^n(-1)^{q+1}\frac 1q\left(\sum_{m=1}^n(1+u)^{m(m-1)/2}\frac {z^m}{m!}\right)^q.$$
So I expanded the power on the sum (with extended binomial theorem) in order to get:
$$q_{n,k} = n!\sum_{q=1}^n(-1)^{q+1}\frac 1q\sum_{\alpha \in \Theta_q}\binom q\alpha\binom {\sum_{m=1}^n\alpha_mm(m-1)/2}k\prod_{m=1}^n\frac 1{(m!)^{\alpha_m}},$$
with $\Theta_q$ the set of all vectors $\alpha \in \mathbb N^n$ such that $\sum_{i=1}^n\alpha_i = q$ and $\sum_{i=1}^ni\alpha_i = n$.
But when implementing this formula, I only get correct results for $n \geq 10$, after that, values differ from Harary & Palmer's one by bigger and bigger amount.
Has anyone any idea of what I could have done wrong ?
In advance, thanks to all,
Bermudes
I'll check my code for my second option as well to see if I missed this one too or if my reasoning is false.
Thanks again for your solution, it helps me a lot.
– Bermudes Apr 22 '17 at 15:07