A215852 Number of simple labeled graphs on n nodes with exactly 2 connected components that are trees or cycles.
1, 3, 19, 135, 1267, 15029, 218627, 3783582, 75956664, 1734309929, 44357222772, 1255715827483, 38971877812380, 1315634598619830, 47994245894462576, 1881406032047006812, 78870928008704884848, 3520953336130828001295, 166762291211479030734580
Offset: 2
Keywords
Examples
a(3) = 3: .1 2. .1-2. .1 2. .|. . . . . . / . .3... .3... .3...
Links
- Alois P. Heinz, Table of n, a(n) for n = 2..145
Programs
-
Maple
T:= proc(n, k) option remember; `if`(k<0 or k>n, 0, `if`(n=0, 1, add(binomial(n-1, i)*T(n-1-i, k-1)* `if`(i<2, 1, i!/2 +(i+1)^(i-1)), i=0..n-k))) end: a:= n-> T(n, 2): seq(a(n), n=2..25);
-
Mathematica
T[n_, k_]:=T[n, k]=If[k<0 || k>n, 0, If[n==0, 1, Sum[Binomial[n - 1, i] T[n - 1 - i, k - 1] If[i<2, 1, i!/2 + (i + 1)^(i - 1)], {i, 0, n - k}]]]; Table[T[n, 2], {n, 2, 50}] (* Indranil Ghosh, Aug 07 2017, after Maple *)
-
Python
from sympy.core.cache import cacheit from sympy import binomial, factorial as f @cacheit def T(n, k): return 0 if k<0 or k>n else 1 if n==0 else sum([binomial(n - 1, i)*T(n - 1 - i, k - 1)*(1 if i<2 else f(i)//2 + (i + 1)**(i - 1)) for i in range(n - k + 1)]) def a(n): return T(n , 2) print([a(n) for n in range(2, 51)]) # Indranil Ghosh, Aug 07 2017, after maple code
Formula
a(n) ~ c * n^(n-2), where c = 0.511564031298... . - Vaclav Kotesovec, Sep 07 2014