A126060 Incorrect version of A001349.
1, 1, 1, 2, 6, 21, 112, 853, 11120
Offset: 0
Keywords
References
- Robin J. Wilson, Introduction to Graph Theory, Academic Press, 1972.
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.
# To produce all graphs on 4 nodes, for example: with(GraphTheory): L:=[NonIsomorphicGraphs](4,output=graphs,outputform=adjacency): # N. J. A. Sloane, Oct 07 2013 seq(GraphTheory[NonIsomorphicGraphs](n,output=count),n=1..10); # Juergen Will, Jan 02 2018 # alternative Maple program: b:= proc(n, i, l) `if`(n=0 or i=1, 1/n!*2^((p-> add(ceil((p[j]-1)/2) +add(igcd(p[k], p[j]), k=1..j-1), j=1..nops(p)))([l[], 1$n])), add(b(n-i*j, i-1, [l[], i$j])/j!/i^j, j=0..n/i)) end: a:= n-> b(n$2, []): seq(a(n), n=0..20); # Alois P. Heinz, Aug 14 2019
Needs["Combinatorica`"] Table[NumberOfGraphs[n], {n, 0, 19}] (* Geoffrey Critzer, Mar 12 2011 *) 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]; edges[v_] := Sum[GCD[v[[i]], v[[j]]], {i, 2, Length[v]}, {j, 1, i - 1}] + Total[Quotient[v, 2]]; a[n_] := Module[{s = 0}, Do[s += permcount[p]*2^edges[p], {p, IntegerPartitions[n]}]; s/n!]; Table[a[n], {n, 0, 20}] (* Jean-François Alcover, Jul 05 2018, after Andrew Howroyd *) b[n_, i_, l_] := If[n==0 || i==1, 1/n!*2^(Function[p, Sum[Ceiling[(p[[j]]-1 )/2]+Sum[GCD[p[[k]], p[[j]]], {k, 1, j-1}], {j, 1, Length[p]}]][Join[l, Table[1, {n}]]]), Sum[b[n-i*j, i-1, Join[l, Table[i, {j}]]]/j!/i^j, {j, 0, n/i}]]; a[n_] := b[n, n, {}]; a /@ Range[0, 20] (* Jean-François Alcover, Dec 03 2019, after Alois P. Heinz *)
permcount(v) = {my(m=1,s=0,k=0,t); for(i=1,#v,t=v[i]; k=if(i>1&&t==v[i-1],k+1,1); m*=t*k;s+=t); s!/m} edges(v) = {sum(i=2, #v, sum(j=1, i-1, gcd(v[i],v[j]))) + sum(i=1, #v, v[i]\2)} a(n) = {my(s=0); forpart(p=n, s+=permcount(p)*2^edges(p)); s/n!} \\ Andrew Howroyd, Oct 22 2017
from itertools import combinations from math import prod, factorial, gcd from fractions import Fraction from sympy.utilities.iterables import partitions def A000088(n): return int(sum(Fraction(1<>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))) # Chai Wah Wu, Jul 02 2024
def a(n): return len(list(graphs(n))) # Ralf Stephan, May 30 2014
From _Gus Wiseman_, Aug 02 2018: (Start) Non-isomorphic representatives of the a(4) = 7 graphs: (12)(34) (12)(13)(14) (12)(13)(24) (12)(13)(14)(23) (12)(13)(24)(34) (12)(13)(14)(23)(24) (12)(13)(14)(23)(24)(34) (End)
b:= proc(n, i, l) `if`(n=0 or i=1, 1/n!*2^((p-> add(ceil((p[j]-1)/2) +add(igcd(p[k], p[j]), k=1..j-1), j=1..nops(p)))([l[], 1$n])), add(b(n-i*j, i-1, [l[], i$j])/j!/i^j, j=0..n/i)) end: a:= n-> b(n$2, [])-`if`(n>0, b(n-1$2, []), 0): seq(a(n), n=0..20); # Alois P. Heinz, Aug 14 2019
<< MathWorld`Graphs` Length /@ (gp = Select[ #, GraphicalPartitionQ] & /@ Graphs /@ Range[9]) nn = 20; g = Sum[NumberOfGraphs[n] x^n, {n, 0, nn}]; CoefficientList[Series[ g (1 - x), {x, 0, nn}], x] (*Geoffrey Critzer, Apr 14 2012*) sysnorm[m_]:=If[Union@@m!=Range[Max@@Flatten[m]],sysnorm[m/.Rule@@@Table[{(Union@@m)[[i]],i},{i,Length[Union@@m]}]],First[Sort[sysnorm[m,1]]]]; sysnorm[m_,aft_]:=If[Length[Union@@m]<=aft,{m},With[{mx=Table[Count[m,i,{2}],{i,Select[Union@@m,#>=aft&]}]},Union@@(sysnorm[#,aft+1]&/@Union[Table[Map[Sort,m/.{par+aft-1->aft,aft->par+aft-1},{0,1}],{par,First/@Position[mx,Max[mx]]}]])]]; Table[Length[Union[sysnorm/@Select[Subsets[Select[Subsets[Range[n]],Length[#]==2&]],Union@@#==Range[n]&]]],{n,6}] (* Gus Wiseman, Aug 02 2018 *) b[n_, i_, l_] := If[n==0 || i==1, 1/n!*2^(Function[p, Sum[Ceiling[(p[[j]]-1)/2] + Sum[GCD[p[[k]], p[[j]]], {k, 1, j-1}], {j, 1, Length[p]}]][Join[l, Table[1, {n}]]]), Sum[b[n-i*j, i-1, Join[l, Table[i, {j}]]]/j!/i^j, {j, 0, n/i}]]; a[n_] := b[n, n, {}] - If[n > 0, b[n-1, n-1, {}], 0]; a /@ Range[0, 20] (* Jean-François Alcover, Dec 03 2019, after Alois P. Heinz *)
from itertools import combinations from math import prod, factorial, gcd from fractions import Fraction from sympy.utilities.iterables import partitions def A002494(n): return int(sum(Fraction(1<>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))-sum(Fraction(1< >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-1))) if n else 1 # Chai Wah Wu, Jul 03 2024
Triangle begins: 1, 1,1, 1,1,1,1, 1,1,2,3,2,1,1, [graphs with 4 nodes and from 0 to 6 edges] 1,1,2,4,6,6,6,4,2,1,1, 1,1,2,5,9,15,21,24,24,21,15,9,5,2,1,1, 1,1,2,5,10,21,41,65,97,131,148,148,131,97,65,41,21,10,5,2,1,1, ...
seq(seq(GraphTheory:-NonIsomorphicGraphs(v,e),e=0..v*(v-1)/2),v=1..9); # Robert Israel, Dec 22 2015
<< Combinatorica`; Table[CoefficientList[GraphPolynomial[n, x], x], {n, 8}] // Flatten (* Eric W. Weisstein, Mar 20 2013 *) << Combinatorica`; Table[NumberOfGraphs[v, e], {v, 8}, {e, 0, Binomial[v, 2]}] // Flatten (* Eric W. Weisstein, May 17 2017 *) 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]; edges[v_, t_] := Product[Product[g = GCD[v[[i]], v[[j]]]; t[v[[i]]*v[[j]]/ g]^g,{j, 1, i-1}], {i, 2, Length[v]}]*Product[c = v[[i]]; t[c]^Quotient[ c-1, 2]*If[OddQ[c], 1, t[c/2]], {i, 1, Length[v]}]; row[n_] := Module[{s = 0}, Do[s += permcount[p]*edges[p, 1 + x^#&], {p, IntegerPartitions[n]}]; s/n!] // Expand // CoefficientList[#, x]&; Array[row, 8] // Flatten (* Jean-François Alcover, Jan 07 2021, after Andrew Howroyd *)
permcount(v) = {my(m=1,s=0,k=0,t); for(i=1,#v,t=v[i]; k=if(i>1&&t==v[i-1],k+1,1); m*=t*k;s+=t); s!/m} edges(v,t) = {prod(i=2, #v, prod(j=1, i-1, my(g=gcd(v[i],v[j])); t(v[i]*v[j]/g)^g )) * prod(i=1, #v, my(c=v[i]); t(c)^((c-1)\2)*if(c%2, 1, t(c/2)))} G(n, A=0) = {my(s=0); forpart(p=n, s+=permcount(p)*edges(p, i->1+x^i+A)); s/n!} { for(n=1, 7, print(Vecrev(G(n)))) } \\ Andrew Howroyd, Oct 22 2019, updated Jan 09 2024
def T(n,k): return len(list(graphs(n, size=k))) # Ralf Stephan, May 30 2014
E.g., a(4)=15 because there are three different (labeled) 4-cycles and 12 different labeled graphs with a 3-cycle and an attached, external vertex.
egf:= -1/2*ln(1+LambertW(-x)) +1/2*LambertW(-x) -1/4*LambertW(-x)^2: a:= n-> n!*coeff(series(egf, x, n+3), x, n): seq(a(n), n=1..25); # Alois P. Heinz, Mar 27 2013
nn=20; t=Sum[n^(n-1) x^n/n!, {n,1,nn}]; Drop[Range[0,nn]! CoefficientList[Series[Log[1/(1-t)]/2-t^2/4-t/2, {x,0,nn}], x], 1] (* Geoffrey Critzer, Oct 07 2012 *) a[n_] := (n-1)!*n^n/2*Sum[1/(n^k*(n-k)!), {k, 3, n}]; Table[a[n], {n, 1, 20}] (* Jean-François Alcover, Jan 15 2014, after Vladeta Jovovic *) csm[s_]:=With[{c=Select[Subsets[Range[Length[s]],{2}],Length[Intersection@@s[[#]]]>0&]},If[c=={},s,csm[Sort[Append[Delete[s,List/@c[[1]]],Union@@s[[c[[1]]]]]]]]]; Table[Length[Select[Subsets[Subsets[Range[n],{2}]],Union@@#==Range[n]&&Length[#]==n&&Length[csm[#]]<=1&]],{n,0,5}] (* Gus Wiseman, Feb 19 2024 *)
# Warning: Floating point calculation. Adjust precision as needed! from mpmath import mp, chop, gammainc mp.dps = 200; mp.pretty = True for n in (1..100): print(chop((n^(n-2)*(1-3*n)+exp(n)*gammainc(n+1, n)/n)/2)) # Peter Luschny, Jan 27 2016
Non-isomorphic representatives of the a(4) = 7 graphs: {{1,2},{1,3},{1,4},{2,3},{2,4}} {{1,2},{1,3},{1,4},{2,3},{2,4},{3,4}}
Table[Length[Select[Subsets[Subsets[Range[n],{2}]], Select[Tuples[#],UnsameQ@@#&]=={}&]],{n,0,5}]
\\ See A004115 for graphsSeries and A339645 for combinatorial species functions. cycleIndexSeries(n)={my(g=graphsSeries(n), gc=sLog(g), gcr=sPoint(gc)); intformal(x*sSolve( sLog( gcr/(x*sv(1)) ), gcr ), sv(1)) + sSolve(subst(gc, sv(1), 0), gcr)} { my(N=12); Vec(OgfSeries(cycleIndexSeries(N)), -N) } \\ Andrew Howroyd, Dec 28 2020
Non-isomorphic representatives of the a(4) = 15 graphs: {{1,2},{1,3},{1,4},{2,3}} {{1,2},{1,3},{2,4},{3,4}}
Table[Length[Select[Subsets[Subsets[Range[n],{2}]], Union@@#==Range[n]&&Length[#]==n&]],{n,0,5}]
a(n) = sum(k=0, n, (-1)^(n-k) * binomial(n,k) * binomial(binomial(k,2), n)) \\ Andrew Howroyd, Dec 29 2023
Comments