A268838
Number of (undirected) Hamiltonian paths in the torus grid graph C_n X C_n.
Original entry on oeis.org
1, 4, 756, 45696, 2955700, 560028096, 126412047692, 93784124187136
Offset: 1
A338963
Number of (undirected) paths in C_n X P_n.
Original entry on oeis.org
1209, 103184, 21272810, 11481159930
Offset: 3
-
# Using graphillion
from graphillion import GraphSet
def make_CnXPk(n, k):
grids = []
for i in range(1, k + 1):
for j in range(1, n):
grids.append((i + (j - 1) * k, i + j * k))
grids.append((i + (n - 1) * k, i))
for i in range(1, k * n, k):
for j in range(1, k):
grids.append((i + j - 1, i + j))
return grids
def A(start, goal, n, k):
universe = make_CnXPk(n, k)
GraphSet.set_universe(universe)
paths = GraphSet.paths(start, goal)
return paths.len()
def A338963(n):
m = n * n
s = 0
for i in range(1, m):
for j in range(i + 1, m + 1):
s += A(i, j, n, n)
return s
print([A338963(n) for n in range(3, 7)])
A003689
Number of Hamiltonian paths in K_3 X P_n.
Original entry on oeis.org
3, 30, 144, 588, 2160, 7440, 24576, 78912, 248448, 771456, 2371968, 7241856, 21998976, 66586752, 201025920, 605781120, 1823094144, 5481472128, 16470172032, 49464779904, 148508372352, 445764192384, 1337792747904
Offset: 1
- F. Faase, On the number of specific spanning subgraphs of the graphs G X P_n, Ars Combin. 49 (1998), 129-154.
- Vincenzo Librandi, Table of n, a(n) for n = 1..1000
- F. Faase, On the number of specific spanning subgraphs of the graphs G X P_n, Preliminary version of paper that appeared in Ars Combin. 49 (1998), 129-154.
- F. Faase, Counting Hamiltonian cycles in product graphs
- F. Faase, Results from the counting program
- Index entries for linear recurrences with constant coefficients, signature (7,-16,12).
-
[3,30] cat [128*3^(n-2)-(21*n+57)*2^(n-2): n in [3..30]]; // Vincenzo Librandi, Apr 27 2014
-
Join[{3,30},LinearRecurrence[{7,-16,12},{144,588,2160},30]] (* Harvey P. Dale, Apr 26 2014 *)
CoefficientList[Series[3 (1 + 3 x - 6 x^2 + 8 x^3 - 4 x^4)/((1 - 3 x) (1 - 2 x)^2), {x, 0, 30}], x] (* Vincenzo Librandi, Apr 27 2014 *)
-
# Using graphillion
from graphillion import GraphSet
def make_CnXPk(n, k):
grids = []
for i in range(1, k + 1):
for j in range(1, n):
grids.append((i + (j - 1) * k, i + j * k))
grids.append((i + (n - 1) * k, i))
for i in range(1, k * n, k):
for j in range(1, k):
grids.append((i + j - 1, i + j))
return grids
def A(start, goal, n, k):
universe = make_CnXPk(n, k)
GraphSet.set_universe(universe)
paths = GraphSet.paths(start, goal, is_hamilton=True)
return paths.len()
def B(n, k):
m = k * n
s = 0
for i in range(1, m):
for j in range(i + 1, m + 1):
s += A(i, j, n, k)
return s
def A003689(n):
return B(3, n)
print([A003689(n) for n in range(1, 21)]) # Seiichi Manyama, Dec 18 2020
A215527
Number of nonintersecting (or self-avoiding) rook paths joining opposite poles of a sphere with n horizontal sectors and n vertical sectors (demarcated by longitudes and latitudes).
Original entry on oeis.org
1, 8, 441, 23436, 3274015, 1279624470, 1429940707685, 4632832974994840, 44016723796115276451, 1236712122885961369684270, 103348977536357696768748889161, 25793194766828189243602379528079372, 19283754194866506189223991782133012219131
Offset: 1
With n=2 there are four sectors: North-Western, North-Eastern, South-Western, South Eastern. Eight nonintersecting (self-avoiding) rook paths joining opposite poles exist:
NorthPole NW SW SouthPole
NorthPole NW SW SE SouthPole
NorthPole NW NE SE SouthPole
NorthPole NW NE SE SW SouthPole
NorthPole NE SE SouthPole
NorthPole NE SE SW SouthPole
NorthPole NE NW SW SouthPole
NorthPole NE NW SW SE SouthPole
So a(2)=8.
-
#include // GCC -O3 // a(7) in ~1.5 hours
char grid[8][8];
long long SIZE;
long long calc_ways(long long x, long long y) {
if (grid[x][y]) return 0;
grid[x][y] = 1;
long long n = calc_ways( x==0? SIZE-1 : x-1, y); // try West
if (SIZE>2)
n+= calc_ways( x==SIZE-1? 0 : x+1, y); // East
if (y>0) n+= calc_ways(x,y-1); // North
if (y==SIZE-1) n++;
else n+= calc_ways(x,y+1); // South
grid[x][y] = 0;
return n;
}
int main(int argc, char **argv)
{
for (SIZE=1; SIZE<7; ++SIZE) {
memset(grid, 0, sizeof(grid));
printf("%llu, ",calc_ways(0,0)*SIZE);
}
printf("\n ");
for (SIZE=3; SIZE<9; ++SIZE) {
unsigned long long r;
memset(grid, 0, sizeof(grid));
grid[0][0]=1;
grid[0][1]=1;
r = calc_ways(0,2)*SIZE; if (SIZE>6) printf(".");
r += calc_ways(1,1)*SIZE*2; if (SIZE>6) printf(".");
grid[0][1]=0;
grid[1][0]=1;
r += calc_ways(1,1)*SIZE*2; if (SIZE>6) printf(".");
r += calc_ways(2,0)*SIZE*2; printf("%llu, ", r);
}
}
A338297
Number of Hamiltonian paths in C_6 X P_n.
Original entry on oeis.org
6, 228, 4800, 76116, 1094316, 14557092, 183735204, 2230289220, 26275912776, 302338568832, 3412921463352, 37923555328200, 415863933818988, 4509400849281240, 48428461587426108, 515767225814395500, 5452991323044249720, 57282647077608267072, 598324561437126968664, 6217929367753246782612
Offset: 1
-
# Using graphillion
from graphillion import GraphSet
def make_CnXPk(n, k):
grids = []
for i in range(1, k + 1):
for j in range(1, n):
grids.append((i + (j - 1) * k, i + j * k))
grids.append((i + (n - 1) * k, i))
for i in range(1, k * n, k):
for j in range(1, k):
grids.append((i + j - 1, i + j))
return grids
def A(start, goal, n, k):
universe = make_CnXPk(n, k)
GraphSet.set_universe(universe)
paths = GraphSet.paths(start, goal, is_hamilton=True)
return paths.len()
def B(n, k):
m = k * n
s = 0
for i in range(1, m):
for j in range(i + 1, m + 1):
s += A(i, j, n, k)
return s
def A338297(n):
return B(6, n)
print([A338297(n) for n in range(1, 11)])
Showing 1-5 of 5 results.
Comments