%I #13 Jul 08 2018 11:09:30
%S 3,18,165,3132,137268,15548004,4679446950,3771927027864,
%T 8186669639820081,48184182482857319682,774912347548961791914585,
%U 34299111628183837790980740312,4205499936656520106909422649497294
%N Number of 2-multigraphs with loops on n nodes.
%C A 2-multigraph is similar to an ordinary graph except there are 0, 1 or 2 edges between any two nodes (self-loops are not allowed).
%H Andrew Howroyd, <a href="/A053513/b053513.txt">Table of n, a(n) for n = 1..50</a>
%t 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 edges[v_] := Sum[GCD[v[[i]], v[[j]]], {i, 2, Length[v]}, {j, 1, i - 1}] + Total[Quotient[v, 2] + 1];
%t a[n_] := (s=0; Do[s += permcount[p]*3^edges[p], {p, IntegerPartitions[n]}]; s/n!);
%t Array[a, 15] (* _Jean-François Alcover_, Jul 08 2018, after _Andrew Howroyd_ *)
%o (PARI)
%o 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}
%o edges(v) = {sum(i=2, #v, sum(j=1, i-1, gcd(v[i],v[j]))) + sum(i=1, #v, v[i]\2 + 1)}
%o a(n) = {my(s=0); forpart(p=n, s+=permcount(p)*3^edges(p)); s/n!} \\ _Andrew Howroyd_, Oct 22 2017
%Y Cf. A000666, A004102, A053514.
%K easy,nonn
%O 1,1
%A _Vladeta Jovovic_, Jan 14 2000
|