The number of paths of the rectangular grid graph 13 x 13

I don’t think you need to program something. Maybe you would need
to program that every vertex is visited. But full hamilton cycles on a rectangular
grid have the invariant that the top left corner alwas looks like this:

+-+ ..
|
+ ..
.
.

So both edges (0,0) - (0,1) and (0,0) - (1,0) are included the hamilton circle.

Now you have already:

It seems to me you can use the above. Just call it with p(0,0)-p(0,1). A non self-
crossing path that visits all vertices, will not include the edge p(0,0)-p(0,1), otherwise
it would be self-crossing. Maybe there are some border cases for small H and W,

don’t know exactly. But I guess it will count open hamilton paths that are not closed
circles. And because of the above mentioned invariant for rectangular grids about the
top left corner it will also count hamilton circles. That would be those paths where

you would flip p(0,0)-p(0,1). The counts for paths and circles should agree.