cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A275165 Number of n-node graphs with two connected components.

This page as a plain text file.
%I A275165 #29 Jul 03 2024 20:06:14
%S A275165 1,1,2,3,9,29,142,998,12145,273400,11991377,1018707920,165078860715,
%T A275165 50500999728875,29053989521340327,31426435300576595334,
%U A275165 64000986599534312456052,245935832697890955733422940,1787577661113111145804012336114,24637809007125076355873926288686728
%N A275165 Number of n-node graphs with two connected components.
%C A275165 "Component" means there are no edges from a node of one component to any node of the other component.
%C A275165 Each of the 2 components may be the empty graph with 0 nodes. That means the graph has only one "visible" component in these cases.
%C A275165 Each of the 2 components must be a connected graph (see A001349). (The empty graph has all properties and is a connected graph.)
%C A275165 The graphs of the components may be the same (=isomorphic).
%H A275165 Alois P. Heinz, <a href="/A275165/b275165.txt">Table of n, a(n) for n = 0..75</a>
%F A275165 G.f.: [A(x)^2 + A(x^2)]/2 where A(x) is the o.g.f. for A001349.
%F A275165 a(n) = A275166(n) if n odd.
%e A275165 a(4)=9 = 1*6 + 1*2 + 1*1 where 1*6=A001349(0)*A001349(4) counts graphs with an empty component and a component with 4 nodes, where 1*2 = A001349(1)*A001349(3) counts graphs with a component of 1 node and a component of 3 nodes, and where 1*1 = A001349(2)*A001349(2) counts graph with a component of 2 nodes and another component of 2 nodes (both components the same in that case).
%t A275165 terms = 20;
%t A275165 mob[m_, n_] := If[Mod[m, n] == 0, MoebiusMu[m/n], 0];
%t A275165 EULERi[b_] := Module[{a, c, i, d}, c = {}; For[i = 1, i <= Length[b], i++,c = Append[c, i*b[[i]] - Sum[c[[d]]*b[[i - d]], {d, 1, i - 1}]]]; a = {}; For[i = 1, i <= Length[b], i++, a = Append[a, (1/i)*Sum[mob[i, d]*c[[d]], {d, 1, i}]]]; Return[a]];
%t A275165 permcount[v_] := Module[{m = 1, s = 0, k = 0, t}, For[i = 1, i <= Length[v], i++, t = v[[i]]; k = If[i > 1 && t == v[[i - 1]], k + 1, 1]; m *= t*k; s += t]; s!/m];
%t A275165 edges[v_] := Sum[GCD[v[[i]], v[[j]]], {i, 2, Length[v]}, {j, 1, i - 1}] +
%t A275165    Total[Quotient[v, 2]];
%t A275165 a88[n_] := Module[{s = 0}, Do[s += permcount[p]*2^edges[p], {p, IntegerPartitions[n]}]; s/n!];
%t A275165 A[x_] = Join[{1}, EULERi[Array[a88, terms]]].(x^Range[0, terms]);
%t A275165 CoefficientList[(A[x]^2 + A[x^2])/2 + O[x]^terms, x] (* _Jean-François Alcover_, May 28 2019, after _Andrew Howroyd_ in A001349 *)
%o A275165 (Python)
%o A275165 from functools import lru_cache
%o A275165 from itertools import combinations
%o A275165 from fractions import Fraction
%o A275165 from math import prod, gcd, factorial, comb
%o A275165 from sympy import mobius, divisors
%o A275165 from sympy.utilities.iterables import partitions
%o A275165 def A275165(n):
%o A275165     @lru_cache(maxsize=None)
%o A275165     def b(n): return int(sum(Fraction(1<<sum(p[r]*p[s]*gcd(r,s) for r,s in combinations(p.keys(),2))+sum((q>>1)*r+(q*r*(r-1)>>1) for q, r in p.items()),prod(q**r*factorial(r) for q, r in p.items())) for p in partitions(n)))
%o A275165     @lru_cache(maxsize=None)
%o A275165     def c(n): return n*b(n)-sum(c(k)*b(n-k) for k in range(1,n))
%o A275165     @lru_cache(maxsize=None)
%o A275165     def d(n): return sum(mobius(n//d)*c(d) for d in divisors(n,generator=True))//n if n else 1
%o A275165     return sum(d(i)*d(n-i) for i in range(n+1>>1)) + (0 if n&1 else comb(d(n>>1)+1,2)) # _Chai Wah Wu_, Jul 03 2024
%Y A275165 Cf. A216785, A001349, A275166, A274934 (no empty components).
%K A275165 nonn
%O A275165 0,3
%A A275165 _R. J. Mathar_, Jul 18 2016