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

%I #21 Feb 16 2025 08:34:01

%S 1,30,235,1448,7909,40674,202719,994268,4837337,23441366,113377235,

%T 547864528,2646278093,12779454410,61709221831,297968336836,

%U 1438739595201,6946894643134,33542671171515,161958548471736,782005482553269,3775857399168946,18231454211243951,88029252078796716

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

%H Seiichi Manyama, <a href="/A339750/b339750.txt">Table of n, a(n) for n = 1..50</a>

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

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

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

%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)

%o return paths.len()

%o def A307026(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 A339750(n):

%o return A307026(n, 2)

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

%Y Row 2 of A307026.

%Y Cf. A288516, A339760.

%K nonn,changed

%O 1,2

%A _Seiichi Manyama_, Dec 15 2020