login
Number of (undirected) Hamiltonian paths in the 2 X n king graph.
6

%I #20 Jan 17 2022 17:32:55

%S 1,12,48,208,768,2752,9472,32000,106496,351232,1150976,3756032,

%T 12222464,39698432,128778240,417398784,1352138752,4378591232,

%U 14175698944,45886734336,148520304640,480679821312,1555633799168,5034389536768,16292153131008,52723609239552,170619454881792,552140862914560

%N Number of (undirected) Hamiltonian paths in the 2 X n king graph.

%H Andrew Howroyd, <a href="/A339760/b339760.txt">Table of n, a(n) for n = 1..500</a> (terms 1..50 from Seiichi Manyama)

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

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

%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (6,-8,-8,16).

%F Empirical g.f.: x*(1 + 6*x - 16*x^2 + 24*x^3 - 16*x^4) / ((1 - 2*x)^2 * (1 - 2*x - 4*x^2)). - _Vaclav Kotesovec_, Dec 16 2020

%F The above formula is correct. - _Andrew Howroyd_, Jan 17 2022

%o (Python)

%o # Using graphillion

%o from graphillion import GraphSet

%o def make_nXk_king_graph(n, k):

%o grids = []

%o for i in range(1, k + 1):

%o for j in range(1, n):

%o grids.append((i + (j - 1) * k, i + j * k))

%o if i < k:

%o grids.append((i + (j - 1) * k, i + j * k + 1))

%o if i > 1:

%o grids.append((i + (j - 1) * k, i + j * k - 1))

%o for i in range(1, k * n, k):

%o for j in range(1, k):

%o grids.append((i + j - 1, i + j))

%o return grids

%o def A(start, goal, n, k):

%o universe = make_nXk_king_graph(n, k)

%o GraphSet.set_universe(universe)

%o paths = GraphSet.paths(start, goal, is_hamilton=True)

%o return paths.len()

%o def B(n, k):

%o m = k * n

%o s = 0

%o for i in range(1, m):

%o for j in range(i + 1, m + 1):

%o s += A(i, j, n, k)

%o return s

%o def A339760(n):

%o return B(n, 2)

%o print([A339760(n) for n in range(1, 21)])

%o (PARI) Vec((1 + 6*x - 16*x^2 + 24*x^3 - 16*x^4) / ((1 - 2*x)^2 * (1 - 2*x - 4*x^2)) + O(x^20)) \\ _Andrew Howroyd_, Jan 17 2022

%Y Row 2 of A350729.

%Y Cf. A308129, A339750, A339761, A339762, A339763.

%K nonn,easy

%O 1,2

%A _Seiichi Manyama_, Dec 16 2020