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.

Showing 1-10 of 48 results. Next

A000666 Number of symmetric relations on n nodes.

Original entry on oeis.org

1, 2, 6, 20, 90, 544, 5096, 79264, 2208612, 113743760, 10926227136, 1956363435360, 652335084592096, 405402273420996800, 470568642161119963904, 1023063423471189431054720, 4178849203082023236058229792, 32168008290073542372004082199424
Offset: 0

Views

Author

Keywords

Comments

Each node may or may not be related to itself.
Also the number of rooted graphs on n+1 nodes.
The 1-to-1 correspondence is as follows: Given a rooted graph on n+1 nodes, replace each edge joining the root node to another node with a self-loop at that node and erase the root node. The result is an undirected graph on n nodes which is the graph of the symmetric relation.
Also the number of the graphs with n nodes whereby each node is colored or not colored. A loop can be interpreted as a colored node. - Juergen Will, Oct 31 2011

References

  • F. Harary and E. M. Palmer, Graphical Enumeration, Academic Press, NY, 1973, pp. 101, 241.
  • M. D. McIlroy, Calculation of numbers of structures of relations on finite sets, Massachusetts Institute of Technology, Research Laboratory of Electronics, Quarterly Progress Reports, No. 17, Sept. 15, 1955, pp. 14-22.
  • R. W. Robinson, Numerical implementation of graph counting algorithms, AGRC Grant, Math. Dept., Univ. Newcastle, Australia, 1976.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A000595, A001172, A001174, A006905, A000250, A054921 (connected relations).

Programs

  • Maple
    # see Riedel link above
  • Mathematica
    Join[{1,2}, Table[CycleIndex[Join[PairGroup[SymmetricGroup[n]], Permutations[Range[n*(n-1)/2+1, n*(n+1)/2]], 2],s] /. Table[s[i]->2, {i,1,n^2-n}], {n,2,8}]] (* Geoffrey Critzer, Nov 04 2011 *)
    Table[Module[{eds,pms,leq},
    eds=Select[Tuples[Range[n],2],OrderedQ];
    pms=Map[Sort,eds/.Table[i->Part[#,i],{i,n}]]&/@Permutations[Range[n]];
    leq=Function[seq,PermutationCycles[Ordering[seq],Length]]/@pms;
    Total[Thread[Power[2,leq]]]/n!
    ],{n,0,8}] (* This is after Geoffrey Critzer's program but does not use the (deprecated) Combinatorica package. - Gus Wiseman, Jul 21 2016 *)
    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[Sum[GCD[v[[i]], v[[j]]], {j, 1, i-1}], {i, 2, Length[v]}] + Sum[Quotient[v[[i]], 2] + 1, {i, 1, Length[v]}];
    a[n_] := a[n] = (s = 0; Do[s += permcount[p]*2^edges[p], {p, IntegerPartitions[n]}]; s/n!);
    Table[Print["a(", n, ") = ", a[n]]; a[n], {n, 0, 17}] (* Jean-François Alcover, Nov 13 2017, after Andrew Howroyd *)
  • PARI
    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 + 1)}
    a(n) = {my(s=0); forpart(p=n, s+=permcount(p)*2^edges(p)); s/n!} \\ Andrew Howroyd, Oct 22 2017
    
  • Python
    from itertools import combinations
    from math import prod, factorial, gcd
    from fractions import Fraction
    from sympy.utilities.iterables import partitions
    def A000666(n): return int(sum(Fraction(1<>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

Formula

Euler transform of A054921. - N. J. A. Sloane, Oct 25 2018
Let G_{n+1,k} be the number of rooted graphs on n+1 nodes with k edges and let G_{n+1}(x) = Sum_{k=0..n(n+1)/2} G_{n+1,k} x^k. Thus a(n) = G_{n+1}(1). Let S_n(x_1, ..., x_n) denote the cycle index for Sym_n. (cf. the link in A000142).
Compute x_1*S_n and regard it as the cycle index of a set of permutations on n+1 points and find the corresponding cycle index for the action on the n(n+1)/2 edges joining those points (the corresponding "pair group"). Finally, by replacing each x_i by 1+x^i gives G_{n+1}(x). [Harary]
Example, n=2. S_2 = (1/2)*(x_1^2+x_2), x_1*S_2 = (1/2)*(x_1^3+x_1*x_2). The pair group is (1/2)*(x_1^2+x_1*x_2) and so G_3(x) = (1/2)*((1+x)^3+(1+x)*(1+x^2)) = 1+2*x+2*x^2+x^3; set x=1 to get a(2) = 6.
a(n) ~ 2^(n*(n+1)/2)/n! [McIlroy, 1955]. - Vaclav Kotesovec, Dec 19 2016

Extensions

Description corrected by Christian G. Bower
More terms from Vladeta Jovovic, Apr 18 2000
Entry revised by N. J. A. Sloane, Mar 06 2007

A002724 Number of inequivalent n X n binary matrices, where equivalence means permutations of rows or columns.

Original entry on oeis.org

1, 2, 7, 36, 317, 5624, 251610, 33642660, 14685630688, 21467043671008, 105735224248507784, 1764356230257807614296, 100455994644460412263071692, 19674097197480928600253198363072, 13363679231028322645152300040033513414, 31735555932041230032311939400670284689732948
Offset: 0

Views

Author

Keywords

Comments

A diagonal of the array A(m,n) described in A028657. - N. J. A. Sloane, Sep 01 2013
Also, number of bipartite graphs with both partite sets of size n, one of which is marked. For connected bipartite graphs, see A363846. - Max Alekseyev, Jun 24 2023

References

  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A028657 (this sequence is the diagonal). - N. J. A. Sloane, Sep 01 2013
Column k=2 of A246106.

Programs

  • Maple
    # See Marko Riedel link.
  • Mathematica
    b[n_, i_] := b[n, i] = If[n == 0, {0}, If[i < 1, {}, Union[Flatten[Table[ Function[{p}, p + j*x^i] /@ b[n - i*j, i - 1], {j, 0, n/i}]]]]];
    g[n_, k_] := g[n, k] = Sum[Sum[2^Sum[Sum[GCD[i, j]*Coefficient[s, x, i]* Coefficient[t, x, j], {j, 1, Exponent[t, x]}], {i, 1, Exponent[s, x]}]/ Product[i^Coefficient[s, x, i]*Coefficient[s, x, i]!, {i, 1, Exponent[s, x]}]/Product[i^Coefficient[t, x, i]*Coefficient[t, x, i]!, {i, 1, Exponent[t, x]}], {t, b[n + k, n + k]}], {s, b[n, n]}];
    A[n_, k_] := g[Min[n, k], Abs[n - k]];
    Table[A[n, n], {n, 0, 15}] (* Jean-François Alcover, Aug 10 2018, after Alois P. Heinz *)
  • PARI
    a(n) = A(n,n) \\ A defined in A028657. - Andrew Howroyd, Mar 01 2023

Formula

a(n) = Sum_{1*s_1+2*s_2+...=n, 1*t_1+2*t_2+...=n} (fixA[s_1, s_2, ...;t_1, t_2, ...]/(1^s_1*s_1!*2^s_2*s_2!*...*1^t_1*t_1!*2^t_2*t_2!*...)) where fixA[...] = 2^Sum_{i, j>=1} (gcd(i, j)*s_i*t_j). - Christian G. Bower, Dec 18 2003
a(n) = A028657(2*n, n). - Max Alekseyev, Jun 24 2023

Extensions

More terms from Vladeta Jovovic, Feb 04 2000
a(15) from Herman Jamke (hermanjamke(AT)fastmail.fm), Feb 24 2008

A006905 Number of transitive relations on n labeled nodes.

Original entry on oeis.org

1, 2, 13, 171, 3994, 154303, 9415189, 878222530, 122207703623, 24890747921947, 7307450299510288, 3053521546333103057, 1797003559223770324237, 1476062693867019126073312, 1679239558149570229156802997, 2628225174143857306623695576671, 5626175867513779058707006016592954, 16388270713364863943791979866838296851, 64662720846908542794678859718227127212465
Offset: 0

Views

Author

Keywords

References

  • D. Ford and J. McKay, personal communication, 1991.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A000595, A001173, A340264. See A091073 for unlabeled case.

Programs

  • Mathematica
    P = Cases[Import["https://oeis.org/A001035/b001035.txt", "Table"], {, }][[All, 2]];
    a[n_] := Sum[P[[k+1]] Sum[Binomial[n, s] StirlingS2[n-s, k-s], {s, 0, k}], {k, 0, n}];
    a /@ Range[0, 18] (* Jean-François Alcover, Dec 29 2019, after Charles R Greathouse IV *)
    transitive[r_]:=Catch[Do[If[a[[2]]==b[[1]]&&FreeQ[r,{a[[1]],b[[2]]}],Throw[False]],{a,r},{b,r}];True];
    a[n_]:=Count[Subsets[Tuples[Range[n],2]],?transitive]; (* _Juan José Alba González, Jul 04 2022 *)
  • PARI
    \\ P = [1, 1, 3, 19, ...] is A001035, starting from 0.
    a(n)=sum(k=0,n,P[k+1]*sum(s=0,k,binomial(n,s)*stirling(n-s,k-s,2)))
    \\ Charles R Greathouse IV, Sep 05 2011

Formula

E.g.f.: A(x + exp(x) - 1) where A(x) is the e.g.f. for A001035. - Geoffrey Critzer, Jul 28 2014

Extensions

More terms from Antonio G. Astudillo (afg_astudillo(AT)lycos.com), Mar 28 2003
a(15)-a(16) from Charles R Greathouse IV, Aug 30 2006
a(17)-a(18) from Charles R Greathouse IV, Sep 05 2011

A001174 Number of oriented graphs (i.e., digraphs with no bidirected edges) on n unlabeled nodes. Also number of complete digraphs on n unlabeled nodes. Number of antisymmetric relations (i.e., oriented graphs with loops) on n unlabeled nodes is A083670.

Original entry on oeis.org

1, 2, 7, 42, 582, 21480, 2142288, 575016219, 415939243032, 816007449011040, 4374406209970747314, 64539836938720749739356, 2637796735571225009053373136, 300365896158980530053498490893399
Offset: 1

Views

Author

Keywords

References

  • F. Harary and E. M. Palmer, Graphical Enumeration, Academic Press, NY, 1973, p. 133, c_p.
  • M. D. McIlroy, Calculation of numbers of structures of relations on finite sets, Massachusetts Institute of Technology, Research Laboratory of Electronics, Quarterly Progress Reports, No. 17, Sept. 15, 1955, pp. 14-22.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A047656 (labeled case), A054941 (connected labeled case), A086345 (connected unlabeled case).

Programs

  • Mathematica
    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 - 1, 2];
    a[n_] := Module[{s = 0}, Do[s += permcount[p]*3^edges[p], {p, IntegerPartitions[n]}]; s/n!];
    Array[a, 15] (* Jean-François Alcover, Jul 06 2018, after Andrew Howroyd *)
  • PARI
    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]-1)\2)}
    a(n) = {my(s=0); forpart(p=n, s+=permcount(p)*3^edges(p)); s/n!} \\ Andrew Howroyd, Oct 23 2017
    
  • Python
    from itertools import combinations
    from math import prod, gcd, factorial
    from fractions import Fraction
    from sympy.utilities.iterables import partitions
    def A001174(n): return int(sum(Fraction(3**(sum(p[r]*p[s]*gcd(r,s) for r,s in combinations(p.keys(),2))+sum((q-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 15 2024

Formula

There's an explicit formula - see for example Harary and Palmer (book), Eq. (5.4.14).
a(n) ~ 3^(n*(n-1)/2)/n! [McIlroy, 1955]. - Vaclav Kotesovec, Dec 19 2016

Extensions

More terms from Vladeta Jovovic
Revised description from Vladeta Jovovic, Jan 20 2005

A326204 Number of Hamiltonian labeled n-vertex digraphs (with loops).

Original entry on oeis.org

0, 2, 4, 120, 19104
Offset: 0

Views

Author

Gus Wiseman, Jun 14 2019

Keywords

Comments

A digraph is Hamiltonian if it contains a directed cycle passing through every vertex exactly once.

Examples

			The a(2) = 4 digraph edge-sets:
  {12,21}
  {11,12,21}
  {12,21,22}
  {11,12,21,22}
		

Crossrefs

The unlabeled case is A326226.
The case without loops is A326219.
The undirected case (without loops) is A326208.
Non-Hamiltonian digraphs are A326220.
Digraphs containing a Hamiltonian path are A326214.

Programs

  • Mathematica
    Table[Length[Select[Subsets[Tuples[Range[n],2]],FindHamiltonianCycle[Graph[Range[n],DirectedEdge@@@#]]!={}&]],{n,0,4}] (* Mathematica 8.0+. Warning: Using HamiltonianGraphQ instead of FindHamiltonianCycle returns a(4) = 19200 which is incorrect *)

A326225 Number of Hamiltonian unlabeled n-vertex digraphs (without loops).

Original entry on oeis.org

0, 1, 1, 4, 61, 3725, 844141, 626078904
Offset: 0

Views

Author

Gus Wiseman, Jun 15 2019

Keywords

Comments

A digraph is Hamiltonian if it contains a directed cycle passing through every vertex exactly once.

Examples

			Non-isomorphic representatives of the a(3) = 4 digraph edge-sets:
  {12,23,31}
  {12,13,21,32}
  {12,13,21,23,31}
  {12,13,21,23,31,32}
		

Crossrefs

The labeled case is A326219.
The case with loops is A326226.
The undirected case is A003216.
Non-Hamiltonian unlabeled digraphs (without loops) are A326222.

Extensions

a(5)-a(7) from Sean A. Irvine, Jun 16 2019

A229865 Number of n X n 0..1 arrays with corresponding row and column sums equal.

Original entry on oeis.org

1, 2, 8, 80, 2432, 247552, 88060928, 112371410944, 523858015518720, 9041009511609073664, 583447777113052431515648, 141885584718620229407228821504, 130832005909904417592540055577034752, 459749137931232137234615429529864283095040, 6182706200522446492946534924719926752508110700544
Offset: 0

Views

Author

R. H. Hardin, Oct 01 2013

Keywords

Comments

Also known as labeled Eulerian digraphs allowing loops. - Brendan McKay, May 12 2019

Examples

			Some solutions for n=4:
  0 0 0 1     0 0 1 0     0 0 0 1     0 0 1 0     0 0 1 1
  0 1 0 0     1 0 0 0     1 0 1 0     0 0 1 1     1 0 0 1
  0 0 0 1     0 1 0 0     0 1 0 1     0 1 1 1     1 1 1 0
  1 0 1 0     0 0 0 1     0 1 1 0     1 1 0 0     0 1 1 1
From _Gus Wiseman_, Jun 22 2019: (Start)
The a(3) = 8 Eulerian digraph edge-sets:
  {}
  {11}
  {22}
  {11,22}
  {12,21}
  {11,12,21}
  {12,21,22}
  {11,12,21,22}
(End)
		

Crossrefs

Column 1 of A229870.
The unlabeled version is A308111.

Programs

  • Mathematica
    Table[Length[Select[Subsets[Tuples[Range[n],2]],Sort[First/@#]==Sort[Last/@#]&]],{n,4}] (* Gus Wiseman, Jun 22 2019 *)

Formula

a(n) = 2^n * A007080(n). - Andrew Howroyd, Sep 11 2019

Extensions

a(0)=1 prepended by Alois P. Heinz, May 14 2019
Terms a(11) and beyond from Andrew Howroyd, Sep 11 2019

A326226 Number of unlabeled n-vertex Hamiltonian digraphs (with loops).

Original entry on oeis.org

0, 2, 3, 24, 858
Offset: 0

Views

Author

Gus Wiseman, Jun 14 2019

Keywords

Comments

A digraph is Hamiltonian if it contains a directed cycle passing through every vertex exactly once.

Examples

			Non-isomorphic representatives of the a(2) = 3 digraph edge-sets:
  {12,21}
  {11,12,21}
  {11,12,21,22}
		

Crossrefs

The labeled case is A326204.
The case without loops is A326225.
The undirected case is A003216 (without loops) or A326215 (with loops).
Unlabeled non-Hamiltonian digraphs are A326223.
Unlabeled digraphs with a Hamiltonian path are A326221.

Programs

  • Mathematica
    dinorm[m_]:=If[m=={},{},If[Union@@m!=Range[Max@@Flatten[m]],dinorm[m/. Apply[Rule,Table[{(Union@@m)[[i]],i},{i,Length[Union@@m]}],{1}]],First[Sort[dinorm[m,1]]]]];
    dinorm[m_,aft_]:=If[Length[Union@@m]<=aft,{m},With[{mx=Table[Count[m,i,{2}],{i,Select[Union@@m,#1>=aft&]}]},Union@@(dinorm[#1,aft+1]&)/@Union[Table[Map[Sort,m/. {par+aft-1->aft,aft->par+aft-1},{0}],{par,First/@Position[mx,Max[mx]]}]]]];
    Table[Length[Select[Union[dinorm/@Subsets[Tuples[Range[n],2]]],FindHamiltonianCycle[Graph[Range[n],DirectedEdge@@@#]]!={}&]],{n,0,4}] (* Mathematica 8.0+. Warning: Using HamiltonianGraphQ instead of FindHamiltonianCycle returns a(4) = 867 which is incorrect *)

A326221 Number of unlabeled n-vertex digraphs (with loops) containing a Hamiltonian path.

Original entry on oeis.org

0, 0, 7, 74, 2395
Offset: 0

Views

Author

Gus Wiseman, Jun 16 2019

Keywords

Comments

A directed path is Hamiltonian if it passes through every vertex exactly once.

Crossrefs

The labeled case is A326214.
The undirected case is A057864 (without loops).
Unlabeled digraphs not containing a Hamiltonian path are A326224.
Unlabeled digraphs containing a Hamiltonian cycle are A326226.

Formula

A000595(n) = a(n) + A326224(n).

A326224 Number of unlabeled n-vertex digraphs (with loops) not containing a Hamiltonian path.

Original entry on oeis.org

1, 2, 3, 30, 649
Offset: 0

Views

Author

Gus Wiseman, Jun 16 2019

Keywords

Comments

A directed path is Hamiltonian if it passes through every vertex exactly once.

Crossrefs

The labeled case is A326213.
The undirected case is A283420 (without loops).
Unlabeled digraphs containing a Hamiltonian path are A326221.
Unlabeled digraphs not containing a Hamiltonian cycle are A326223.

Formula

A000595(n) = a(n) + A326221(n).
Showing 1-10 of 48 results. Next