login
Number of (undirected) cycles in the n-Pell graph.
1

%I #12 Jan 18 2024 16:24:13

%S 0,1,65,4983940

%N Number of (undirected) cycles in the n-Pell graph.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/GraphCycle.html">Graph Cycle</a>.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PellGraph.html">Pell Graph</a>.

%o (Python)

%o from itertools import product, combinations, groupby, islice

%o from networkx import empty_graph, simple_cycles

%o def A368189(n):

%o if n<=1 : return 0

%o G = empty_graph(v for v in product((0,1,2),repeat=n) if not any(len(list(g))&1 and k==2 for k, g in groupby(v)))

%o for a, b in combinations(G,2):

%o r = tuple(islice((i for i in range(n) if a[i]!=b[i]),3))

%o if len(r)==1 and a[r[0]]!=2 and b[r[0]]!=2:

%o G.add_edge(a,b)

%o elif len(r)==2 and r[0]+1==r[1] and a[r[0]] and b[r[0]] and a[r[0]]==a[r[1]] and b[r[0]]==b[r[1]]:

%o G.add_edge(a,b)

%o return sum(1 for c in simple_cycles(G)) # _Chai Wah Wu_, Jan 18 2024

%K nonn,more

%O 1,3

%A _Eric W. Weisstein_, Dec 16 2023