2

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

Bermudes
  • 495
  • 4
  • 15
  • For what it's worth I looked up the Maple code from the link among my records and ran all five generating functions for $n=12$. They all return the same value, namely $73354596206766622208$ which is also listed in OEIS A001187. This entry as well as the fact that we computed the value by five different methods should be considered solid evidence that the formulae in the post are correct. I suggest you continue debugging your code, perhaps by computing the values for $k$ edges which might help you locate your problem. – Marko Riedel Apr 21 '17 at 22:34
  • By debugging (again) my source code and writing it in Maxima, I eventually got the correct results. I already checked for $k$ edges individually, and difference between correct and incorrect result was negative half the time, and positive the rest of the iterations.

    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
  • @Bermudes can you please point me to the source where you find harary and palmers formula ? I cant find it in their book? Thanks alot! (I mean the formula for enumerating connected graphs with $n$ vertices and $k$ edges) – SagarM Jun 15 '21 at 11:04
  • 1
    @SagarM the recurrencce is the one about the number of connected graphs with p vertices and is given in equation 1.2.1 of Harary & Palmer's Graphical Enumeration. – Bermudes Jun 16 '21 at 21:08

0 Answers0