Next Article in Journal
Experimental Validation of Fractional PID Controllers Applied to a Two-Tank System
Previous Article in Journal
A Novel High-Speed and Low-PDP Approximate Full Adder Cell for Image Blending
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Counting Traversing Hamiltonian Cycles in Tiled Graphs

by
Alen Vegi Kalamar
1,2
1
Department of Mathematics and Computer Science, University of Maribor, 2000 Maribor, Slovenia
2
Comtrade Gaming, 2000 Maribor, Slovenia
Mathematics 2023, 11(12), 2650; https://doi.org/10.3390/math11122650
Submission received: 25 April 2023 / Revised: 4 June 2023 / Accepted: 9 June 2023 / Published: 10 June 2023

Abstract

:
Recently, the problem of counting Hamiltonian cycles in 2-tiled graphs was resolved by Vegi Kalamar, Bokal, and Žerak. In this paper, we continue our research on generalized tiled graphs. We extend algorithms on counting traversing Hamiltonian cycles from 2-tiled graphs to generalized tiled graphs. We further show that, similarly as for 2-tiled graphs, for a fixed finite set of tiles, counting traversing Hamiltonian cycles can be performed in linear time with respect to the size of such graph, implying that counting traversing Hamiltonian cycles in tiled graphs is fixed-parameter tractable.

1. Introduction

Interest in the enumeration and generation of Hamiltonian cycles in various families of graphs can be found in different domains of science. In chemistry, theoretical physics, and biophysics, the research is connected to the modeling of polymers [1], polymer melting, protein folding [2], and the study of magnetic systems with O ( n ) symmetry [3]. In the theory of algorithms, it is one of the most studied counting problems coming from the mathematical nanosciences [4]. It has applications in coding theory according to [5,6,7]. In engineering and bioinformatics, the research is connected to security and intellectual property protection [8] and path planning problems for robots and machine tools [9].
Studies on the topic of counting Hamiltonian cycles in different families of graphs and the use of similar (matrix) approaches are not negligible. In 1990, a characterization of Hamiltonian cycles of the Cartesian product P 4 × P n was established [10]. In 1994, Kwong and Rogers developed a matrix method for counting Hamiltonian cycles in P m × P n , obtaining exact results for m = 4 , 5 [11]. Their method was extended to arbitrarily large grids by Bodroža-Pantić et al. [12] and by Stoyan and Strehl [13]. Later, Bodroža-Pantić et al. gave some explicit generating functions for the number of Hamiltonian cycles in graphs P m × P n , C m × P n and P m × C n [14,15,16]. Recently, Đokić et al. presented two algorithms for determination of the number of (all spanning unions of cycles) 2-factors in three classes of grid graphs: the thin cylinder T n C m ( n ) , torus T G m ( p ) ( n ) , and Klein bottle K B m ( p ) ( n ) , all of which had a width of m [17]. On the other hand, Vegi Kalamar et al. characterized all Hamiltonian cycles in 2-tiled graphs and efficiently counted them for a fixed family of tiles [18]. Others have recently tackled other (less related) families of graphs: Fernandes et al. on the Matroid Basis Graph [19], Liu et al. on planar triangulations [20] and Ferber et al. on Dirac Hypergraphs [21].
In the present contribution, we build on the results of [18]. The introduced k-traversing Hamiltonian cycles in tiled graphs are a generalization of zigzagging (1-traversing) and traversing (2-traversing) Hamiltonian cycles from 2-tiled graphs. We extend the results to counting traversing Hamiltonian cycles in an arbitrary family of tiled graphs.
We organize the remainder of the paper as follows. In Section 2, we define tiled graphs as a generalization of 2-tiled graphs, define traversing Hamiltonian cycles in tiled graphs, and prove their possible existence. In Section 3, we present an algorithm to count this type of Hamiltonian cycles and represent its value in a closed formula. In Section 4, we propose open problems for further research.

2. Tiled Graphs and Traversing Hamiltonian Cycles

In this section, we introduce the concept of a tile as presented in [18] and extend it to a definition of a tiled graph. We define the concept of k-traversing Hamiltonian cycles in tiled graphs and prove their possible existence for certain values of k.
Definition 1. 
A tile is a triple T = ( G , x , y ) , consisting of a connected graph G and two sequences x = ( x 1 , x 2 , , x k ) (left wall) and y = ( y 1 , y 2 , , y l ) (right wall) of distinct vertices of G, with no vertex of G appearing in both x and y. We call T a ( k , l ) -tile.
Example 1 
(A tile). Same graph represented as a (2,3)-tile with one internal vertex and as a (3,3)-tile without an internal vertex.
Mathematics 11 02650 i001
Definition 2. 
1. 
The tiles T = ( G , x , y ) and T = ( G , x , y ) are compatible whenever | y | = | x | .
2. 
A sequence T = ( T 0 , T 1 , , T m ) of tiles is compatible if, for each i { 1 , 2 , , m } , T i 1 is compatible with T i .
3. 
The join of compatible tiles ( G , x , y ) and ( G , x , y ) is the tile T = ( G , x , y ) ( G , x , y ) for which the graph is obtained from disjoint union of G and G by identifying the sequence y term by term with the sequence x .
4. 
The join of a compatible sequence T = ( T 0 , T 1 , , T m ) of tiles is defined as T = T 0 T 1 T m .
5. 
A tile T is cyclically compatible if T is compatible with itself.
6. 
For a cyclically compatible tile T = ( G , x , y ) , the cyclization of T is the graph T obtained by identifying the respective vertices of x with y.
7. 
A cyclization of a cyclically compatible sequence of tiles T is defined as T = ( T ) .
8. 
A tiled graph is a cyclization of a sequence of at least 3 tiles.
Example 2 
(Join of tiles). Result of a join of tiles from the left side is a (2,2)-tile on the right side.
Mathematics 11 02650 i002
Example 3 
(Cyclization of a tile). Cyclization of the left side tile results in a graph where the vertices of the left wall are identified with the vertices of the right wall.
Mathematics 11 02650 i003
The following lemma is crucial in understanding of a structure of Hamiltonian cycles in tiled graphs. It is an extension of claims 1–3 of Lemma 1 from [18] to tiled graphs.
Lemma 1. 
Let C be a Hamiltonian cycle in a tiled graph G = ( T 0 , T 1 , , T m ) . Then, we have the following:
1. 
C = i = 0 m ( C T i ) .
2. 
C T i is a union of paths and isolated vertices.
3. 
Let v be a vertex of a component of C T i . Then, v has degree 2 in C T i or v is a wall vertex.
Proof. 
1.
C = C G = C i = 0 m T i = Distributive law i = 0 m ( C T i ) .
2.
Let K be a component of C T i . As C is a cycle, K is a connected subgraph of C. Then, K is either equal to C, a path, or a vertex. If K = C , then T i contains all the vertices of G, a contradiction to m 2 (in at least one tile, C does not contain all the vertices). The claim follows.
3.
Let v be a vertex of C T i of degree different from 2. As the maximum degree of vertex in C is 2, v has degree 1 or 0. If v is an internal vertex of T i , its degree in C = i = 0 m ( C T i ) is equal to its degree in C T i . This contradicts C being a cycle and the claim follows.
 □
Definition 3. 
Let G = ( T 0 , T 1 , , T m ) be a tiled graph and N i the set of all isolated vertices in C T i . For k N , Hamiltonian cycle C is k-traversing, if i { 0 , 1 , , m } , ( C T i ) \ N i is a set of k paths that start in a vertex of left wall and end in a vertex of right wall that cover all internal vertices of T i .
Definition 4. 
Let G = ( T 0 , T 1 , , T m ) be a tiled graph, where i , T i is a ( k i , l i ) -tile. The minimum wall size of a tiled graphs G is defined as min w s ( G ) = min { k 0 , k 1 , , k m } .
The following result (using claim 4 of Lemma 1 from [18] as a basis) directly follows from claims of Lemma 1.
Corollary 1. 
Let G = ( T 0 , T 1 , , T m ) be a tiled graph, where i , T i is a ( k i , l i ) -tile. If a k-traversing Hamiltonian cycle exists in G, then k min w s ( G ) .
Proof. 
By Claim 3 in Lemma 1, paths start and end in a wall vertex. Each traversing path is a distinct non-degenerate path and has at least two unique wall vertices, one from the left wall and one from the right wall. For a tile T i , the number of such paths is at most min { k i , l i } and the claim for the whole graph follows from the fact that G = ( T 0 , T 1 , , T m ) .  □

3. Counting Traversing Hamiltonian Cycles in Tiled Graphs

In this section, we introduce structures that enable us to describe an algorithm for counting traversing Hamiltonian cycles and prove its correctness. We further show that, in the case of a fixed set of tiles, this algorithm is efficient.
According to Definition 3, k-traversing Hamiltonian cycles can be obtained by “gluing” k disjoint paths covering all internal nodes of a tile between neighboring tiles. We must pay attention to the following things:
1.
Each of the k paths in a tile has to be “glued together” with exactly one of the k paths in the neighboring tile.
2.
When we “glue” all k paths in neighboring tiles, on a shared wall each node must belong to exactly on of the k paths.
3.
When “gluing together” k paths in the entire tiled graph, we must make sure that this is conducted in such a way that these “glued” k paths result in a single cycle.
In the following, we present the structures that will help us solve the presented challenges. To facilitate brevity, we have prepared Table A1 with a summary of frequently used notations. It is located in Appendix A.
Let G = ( T 0 , T 1 , , T m ) be a tiled graph, where i , T i is a ( k i , l i ) -tile. For a tile T i , let k [ min { k i , l i } ] . Let k L i e be a set of strings of left endvertices of length k (out of k i options) and k R i e be a set of strings of right endvertices of length k (out of l i options), both ordered lexicographically from smallest to largest. Then, | k L i e | = k i k k ! and | k R i e | = l i k k ! . Those sets will be used to model left-to-right transition modes. Let ϵ denote an empty string. Additionally, let k L i r be a set of all binary strings of length k i k (for remaining k i k left wall vertices) and k R i r a set of all binary strings of length l i k (for remaining l i k left wall vertices),
k L i r = { ϵ } , k = k i { 0 , 1 } k i k , otherwise , k R i r = { ϵ } , k = l i { 0 , 1 } l i k , otherwise ,
both ordered lexicographically from largest to smallest. Then, | k L i r | = 2 k i k and | k R i r | = 2 l i k . Those sets will be used to model the coverage of wall vertices with paths within the current (bit value 1) or a neighboring tile (bit value 0). For element x from sets k L i r and k R i r , let x ¯ denote a string where all bits are flipped and ϵ ¯ = ϵ .
Let k i A be a | k L i e | × | k R i e | block matrix
k i A = k i A b 1 , c 1 k i A b 1 , c 2 k i A b 1 , c | k R i e | k i A b 2 , c 1 k i A b 2 , c 2 k i A b 2 , c | k R i e | k i A b | k L i e | , c 1 k i A b | k L i e | , c 2 k i A b | k L i e | , c | k R i e | ,
where, p [ | k L i e | ] , b p k L i e (p-th element in k L i e ) and r [ | k R i e | ] , c r k R i e (r-th element in k R i e ), k i A b p , c r is a | k L i r | × | k R i r | matrix of form
k i a b p , c r d 1 , e 1 k i a b p , c r d 1 , e 2 k i a b p , c r d 1 , e | k R i r | k i a b p , c r d 2 , e 1 k i a b p , c r d 2 , e 2 k i a b p , c r d 2 , e | k R i r | k i a b p , c r d | k L i r | , e 1 k i a b p , c r d | k L i r | , e 2 k i a b p , c r d | k L i r | , e | k R i r | ,
where, u [ | k L i r | ] , d u k L i r (u-th element in k L i r ), and v [ | k R i r | ] , e v k R i r (v-th element in k R i r ), k i a b p , c r d u , e v represents the number of possible combinations in T i for k distinct paths covering all internal vertices that have ordered left wall endvertices b p and ordered right wall endvertices c r (defining paths b p 1 c r 1 , b p 2 c r 2 , , b p k c r k ), d u describing if remaining k i k left wall vertices are/are not part of any k paths and e v describing if remaining l i k right wall vertices are/are not part of any k paths.
Example 4. 
Let T be a (2,3)-tiled graph with no internal (non-wall) vertex. Then, there may exist 1-traversing and 2-traversing paths:
  • 1-traversing: In this case, the sets L e , R e , L r , R r are the following:
    1 L e = { 1 , 2 } , 1 R e = { 1 , 2 , 3 } , 1 L r = { 1 , 0 } , 1 R r = { 11 , 10 , 01 , 00 } .
    Then
    1 A = 1 A 1 , 1 1 A 1 , 2 1 A 1 , 3 1 A 2 , 1 1 A 2 , 2 1 A 2 , 3 ,
    where i L e , j R e
    1 A i , j = 1 a i , j 1 , 11 1 a i , j 1 , 10 1 a i , j 1 , 01 1 a i , j 1 , 00 1 a i , j 0 , 11 1 a i , j 0 , 10 1 a i , j 0 , 01 1 a i , j 0 , 00 .
    For example, 1 a 1 , 2 1 , 10 denotes the number of possible combinations in T for one path covering all internal vertices, starting in x 1 , ending in y 2 , where the first remaining left wall vertex ( x 2 ) is part of the path and the first remaining right wall vertex ( y 1 ) is part of the path, but the second one ( y 3 ) is not. See Figure 1.
  • 2-traversing: In this case, the sets L e , R e , L r , R r are the following:
    2 L e = { 12 , 21 } , 2 R e = { 12 , 13 , 21 , 23 , 31 , 32 } , 2 L r = { ϵ } , 2 R r = { 1 , 0 } .
    Then
    2 A = 2 A 12 , 12 2 A 12 , 13 2 A 12 , 21 2 A 12 , 23 2 A 12 , 31 2 A 12 , 32 2 A 21 , 12 2 A 21 , 13 2 A 21 , 21 2 A 21 , 23 2 A 21 , 31 2 A 21 , 32 ,
    where i L e , j R e ,
    2 A i , j = 2 a i , j ϵ , 1 2 a i , j ϵ , 0 .
    For example, 2 a 21 , 23 ϵ , 1 denotes the number of possible combinations in T for two distinct paths covering all internal vertices, the first starting in x 2 and ending in y 2 , and second one starting in x 1 and ending in y 3 , where there is no remaining left wall vertex and the first remaining right wall vertex ( y 1 ) is part of one of the paths. See Figure 2.
Let k i A ¯ be a | k L i e | × | k R i e | block matrix
k i A ¯ = k i A ¯ b 1 , c 1 k i A ¯ b 1 , c 2 k i A ¯ b 1 , c | k R i e | k i A ¯ b 2 , c 1 k i A ¯ b 2 , c 2 k i A ¯ b 2 , c | k R i e | k i A ¯ b | k L i e | , c 1 k i A ¯ b | k L i e | , c 2 k i A ¯ b | k L i e | , c | k R i e | ,
where, p [ | k L i e | ] , b p k L i e (p-th element in k L i e ) and r [ | k R i e | ] , c r k R i e (r-th element in k R i e ), k i A ¯ b p , c r is a | k L i r | × | k R i r | matrix of form
k i a b p , c r d 1 ¯ , e 1 k i a b p , c r d 1 ¯ , e 2 k i a b p , c r d 1 ¯ , e | k R i r | k i a b p , c r d 2 ¯ , e 1 k i a b p , c r d 2 ¯ , e 2 k i a b p , c r d 2 ¯ , e | k R i r | k i a b p , c r d | k L i r | ¯ , e 1 k i a b p , c r d | k L i r | ¯ , e 2 k i a b p , c r d | k L i r | ¯ , e | k R i r | .
Example 5. 
Using tile from Example 4, we check the k A ¯ matrices:
  • 1-traversing:
    1 A ¯ = 1 A ¯ 1 , 1 1 A ¯ 1 , 2 1 A ¯ 1 , 3 1 A ¯ 2 , 1 1 A ¯ 2 , 2 1 A ¯ 2 , 3 ,
    where i L e , j R e
    1 A ¯ i , j = 1 a i , j 1 ¯ , 11 1 a i , j 1 ¯ , 10 1 a i , j 1 ¯ , 01 1 a i , j 1 ¯ , 00 1 a i , j 0 ¯ , 11 1 a i , j 0 ¯ , 10 1 a i , j 0 ¯ , 01 1 a i , j 0 ¯ , 00 = 1 a i , j 0 , 11 1 a i , j 0 , 10 1 a i , j 0 , 01 1 a i , j 0 , 00 1 a i , j 1 , 11 1 a i , j 1 , 10 1 a i , j 1 , 01 1 a i , j 1 , 00 .
  • 2-traversing:
    2 A ¯ = 2 A ¯ 12 , 12 2 A ¯ 12 , 13 2 A ¯ 12 , 21 2 A ¯ 12 , 23 2 A ¯ 12 , 31 2 A ¯ 12 , 32 2 A ¯ 21 , 12 2 A ¯ 21 , 13 2 A ¯ 21 , 21 2 A ¯ 21 , 23 2 A ¯ 21 , 31 2 A ¯ 21 , 32 ,
    where i L e , j R e
    2 A ¯ i , j = 2 a i , j ϵ ¯ , 1 2 a i , j ϵ ¯ , 0 = 2 a i , j ϵ , 1 2 a i , j ϵ , 0 .
Definition 5. 
Let T i be a ( k i , l i ) -tile and T i + 1 a ( k i + 1 , l i + 1 ) -tile that are compatible ( l i = k i + 1 ). For k [ min { k i , l i , l i + 1 } ] , let k i A be a matrix that belongs to T i and k i + 1 A ¯ a matrix that belongs to T i + 1 . For a tile T i T i + 1 , we define a matrix k i , i + 1 A as
k i , i + 1 A = k i A · k i + 1 A ¯ ,
where · represents the block matrix multiplication
k i , i + 1 A b p , c r = x k R i e = k L i + 1 e k i A b p , x · k i + 1 A ¯ x , c r .
Lemma 2. 
Matrix k i , i + 1 A is a | k L i e | × | k R i + 1 e | block matrix of form
k i , i + 1 A b 1 , c 1 k i , i + 1 A b 1 , c 2 k i , i + 1 A b 1 , c | k R i e | k i , i + 1 A b 2 , c 1 k i , i + 1 A b 2 , c 2 k i , i + 1 A b 2 , c | k R i e | k i , i + 1 A b | k L i e | , c 1 k i , i + 1 A b | k L i e | , c 2 k i , i + 1 A b | k L i e | , c | k R i e | ,
where, p [ | k L i e | ] , b p k L i e (p-th element in k L i e ) and r [ | k R i + 1 e | ] , c r k R i + 1 e (r-th element in k R i + 1 e ), k i , i + 1 A b p , c r is a | k L i r | × | k R i + 1 r | matrix of form
k i , i + 1 a b p , c r d 1 , e 1 k i , i + 1 a b p , c r d 1 , e 2 k i , i + 1 a b p , c r d 1 , e | k R i + 1 r | k i , i + 1 a b p , c r d 2 , e 1 k i , i + 1 a b p , c r d 2 , e 2 k i , i + 1 a b p , c r d 2 , e | k R i + 1 r | k i , i + 1 a b p , c r d | k L i r | , e 1 k i , i + 1 a b p , c r d | k L i r | , e 2 k i , i + 1 a b p , c r d | k L i r | , e | k R i + 1 r | ,
where, u [ | k L i r | ] , d u k L i r (u-th element in k L i r ), and v [ | k R i + 1 r | ] , e v k R i + 1 r (v-th element in k R i + 1 r ), k i , i + 1 a b p , c r d u , e v represents the number of possible combinations in T i T i + 1 for k distinct paths covering all internal vertices that have ordered left wall endvertices b p and ordered right wall endvertices c r (defining paths b p 1 c r 1 , b p 2 c r 2 , , b p k c r k ), d u describing if remaining k i k left wall vertices are/are not part of any k paths and e v describing if remaining l i + 1 k right wall vertices are/are not part of any k paths.
Remark 1. 
Lemma 2 presents the counting of ways of “gluing” k paths in adjacent tiles.
Proof. 
Because tiles T i and T i + 1 are compatible, k R i e = k L i + 1 e and k R i r = k L i + 1 r . Since k i A is a block matrix of dimension | k L i e | × | k R i e | and k i + 1 A ¯ is a block matrix of dimension | k L i + 1 e | × | k R i + 1 e | , by definition of block matrix multiplication, k i , i + 1 A is a block matrix of dimension | k L i e | × | k R i + 1 e | . Since each block in k i A is of dimension | k L i r | × | k R i r | and each block in k i + 1 A ¯ of dimension | k L i + 1 r | × | k R i + 1 r | , by definition of block matrix multiplication, each block k i , i + 1 A b p , c r in k i , i + 1 A is of dimension | k L i r | × | k R i + 1 r | .
By definition of block matrix multiplication, element k i , i + 1 a b p , c r d u , e v of block k i , i + 1 A b p , c r is calculated as
k i , i + 1 a b p , c r d u , e v = x k R i e y k R i r k i a b p , x d u , y · k i + 1 a x , c r y ¯ , e v .
We have to show that x k R i e , y k R i r ,
k i a b p , x d u , y · k i + 1 a x , c r y ¯ , e v
generates described paths in T i T i + 1 .
Let x k R i e and y k R i r . Then, k i a b p , x d u , y represents the number of possible combinations in T i for k distinct paths covering all internal vertices that have ordered left wall endvertices b p and ordered right wall endvertices x (defining paths b p 1 x 1 , b p 2 x 2 , , b p k x k ), d u describing if remaining k i k left wall vertices are/are not part of any k paths and y describing if remaining l i k right wall vertices are/are not part of any k paths. On the other side, k i + 1 a x , c r y ¯ , e v represents the number of possible combinations in T i + 1 for k distinct paths covering all internal vertices that have ordered left wall endvertices x and ordered right wall endvertices c r (defining paths x 1 c r 1 , x 2 c r 2 , , x k c r k ), y ¯ describing if remaining k i + 1 k left wall vertices are/are not part of any k paths and e v describing if remaining l i + 1 k right wall vertices are/are not part of any k paths.
It is clear that, if we identify those k paths by endvertices x (defining paths b p 1 x 1 c r 1 , b p 2 x 2 c r 2 , , b p k x k c r k ), we cover all internal vertices in T i and T i + 1 , but also remaining vertices on shared wall (paths in T i cover remaining right wall vertices in T i , for which the bit value in y is 1, and paths in T i + 1 cover remaining left wall vertices in T i + 1 , for which the bit value in y ¯ is 1) and the result follows. □
Example 6. 
We check out the product k 1 A · k 2 A ¯ , where T 1 is a tile from Example 4 and T 2 the tile that we obtain if we switch walls in T 1 (those tiles are compatible).
  • 1-traversing:
    1 1 , 2 A = 1 1 A · 1 2 A ¯ = 1 1 A 1 , 1 1 1 A 1 , 2 1 1 A 1 , 3 1 1 A 2 , 1 1 1 A 2 , 2 1 1 A 2 , 3 · 1 2 A ¯ 1 , 1 1 2 A ¯ 1 , 2 1 2 A ¯ 2 , 1 1 2 A ¯ 2 , 2 1 2 A ¯ 3 , 1 1 2 A ¯ 3 , 2 = 1 1 , 2 A 1 , 1 1 1 , 2 A 1 , 2 1 1 , 2 A 2 , 1 1 1 , 2 A 2 , 2 ,
    where i L e , j R e
    1 1 , 2 A i , j = x k R e 1 1 A i , x · 1 2 A ¯ x , j .
  • 2-traversing:
    2 1 , 2 A = 2 1 A · 2 2 A ¯ = 2 1 A 12 , 12 2 1 A 12 , 13 2 1 A 12 , 21 2 1 A 12 , 23 2 1 A 12 , 31 2 1 A 12 , 32 2 1 A 21 , 12 2 1 A 21 , 13 2 1 A 21 , 21 2 1 A 21 , 23 2 1 A 21 , 31 2 1 A 21 , 32 · 2 2 A ¯ 12 , 12 2 2 A ¯ 12 , 21 2 2 A ¯ 13 , 12 2 2 A ¯ 13 , 21 2 2 A ¯ 21 , 12 2 2 A ¯ 21 , 21 2 2 A ¯ 23 , 12 2 2 A ¯ 23 , 21 2 2 A ¯ 31 , 12 2 2 A ¯ 31 , 21 2 2 A ¯ 32 , 12 2 2 A ¯ 32 , 21 = 2 1 , 2 A 12 , 12 2 1 , 2 A 12 , 21 2 1 , 2 A 21 , 12 2 1 , 2 A 21 , 21 ,
    where i L e , j R e
    2 1 , 2 A i , j = x k R e 2 1 A i , x · 2 2 A ¯ x , j .
Definition 6. 
For j > 1 , we define
k i , i + j A = k i , i + j 1 A · k i + j A ¯ .
Definition 7. 
For b = b 1 b 2 b k L 0 e and z [ k ] , let
b z = b k z + 1 b k b 1 b k z
be the z-shift of b.
Theorem 1. 
Let G = ( T 0 , T 1 , , T m ) be a tiled graph and let k min w s ( G ) . The number of distinct k-traversing Hamiltonian cycles in G is equal to
k T H C ( G ) = b k L 0 e s = 1 | k L 0 r | k 0 , m a b , b d s , d | k L 0 r | + 1 s , if k = 1 , 1 k ! b k L 0 e z = 1 k 1 s = 1 | k L 0 r | k 0 , m a b , b z d s , d | k L 0 r | + 1 s , if k > 1 .
Proof. 
Let k 0 , m A be a matrix that belongs to T 0 T 1 T m . Then, it is a | k L 0 e | × | k R m e | block matrix of form
k 0 , m A b 1 , c 1 k 0 , m A b 1 , c 2 k 0 , m A b 1 , c | k R m e | k 0 , m A b 2 , c 1 k 0 , m A b 2 , c 2 k 0 , m A b 2 , c | k R m e | k 0 , m A b | k L 0 e | , c 1 k 0 , m A b | k L 0 e | , c 2 k 0 , m A b | k L 0 e | , c | k R m e | ,
where p [ | k L 0 e | ] , b p k L 0 e (p-th element in k L 0 e ), r [ | k R m e | ] , c r (r-th element in k R m e ), k 0 , m A b p , c r is a | k L 0 r | × | k R m r | matrix of form
k 0 , m a b p , c r d 1 , e 1 k 0 , m a b p , c r d 1 , e 2 k 0 , m a b p , c r d 1 , e | k R m r | k 0 , m a b p , c r d 2 , e 1 k 0 , m a b p , c r d 2 , e 2 k 0 , m a b p , c r d 2 , e | k R . r | k 0 , m a b p , c r d | k L 0 r | , e 1 k 0 , m a b p , c r d | k L 0 r | , e 2 k 0 , m a b p , c r d | k L 0 r | , e | k R m r | .
Since graph G is a result of identifications of left and right wall vertices in tile T 0 T 1 T m , k 0 = l m and so k L 0 e = k R m e and k L 0 r = k R m r . We obtain that matrix k 0 , m A is a | k L 0 e | × | k L 0 e | block matrix of form
k 0 , m A b 1 , b 1 k 0 , m A b 1 , b 2 k 0 , m A b 1 , b | k L 0 e | k 0 , m A b 2 , b 1 k 0 , m A b 2 , b 2 k 0 , m A b 2 , b | k L 0 e | k 0 , m A b | k L 0 e | , b 1 k 0 , m A b | k L 0 e | , b 2 k 0 , m A b | k L 0 e | , b | k L 0 e | ,
where p , r [ | k L 0 e | ] , b p , b r k L 0 e (p-th and r-th element in k L 0 e ), k 0 , m A b p , b r is a | k L 0 r | × | k L 0 r | matrix of form
k 0 , m a b p , b r d 1 , d 1 k 0 , m a b p , b r d 1 , d 2 k 0 , m a b p , b r d 1 , d | k L 0 r | k 0 , m a b p , b r d 2 , d 1 k 0 , m a b p , b r d 2 , d 2 k 0 , m a b p , b r d 2 , d | k L 0 r | k 0 , m a b p , b r d | k L 0 r | , d 1 k 0 , m a b p , b r d | k L 0 r | , d 2 k 0 , m a b p , b r d | k L 0 r | , d | k L 0 r | ,
where, u , v [ | k L 0 r | ] , d u , d v k L 0 r (u-th and v-th element in k L 0 r ), k i a b p , b r d u , d v represents the number of possible combinations in T 0 T 1 T m for k distinct paths covering all internal vertices that have ordered left wall endvertices b p and ordered right wall endvertices b r (defining paths b p 1 b r 1 , b p 2 b r 2 , , b p k b r k ), d u describing remaining k 0 k left wall vertices are/are not part of any k paths and d v describing remaining k 0 k right wall vertices are/are not part of any k paths.
To obtain the number k T H C ( G ) from the matrix k 0 , m A , we need to take into account only block matrices k 0 , m A b p , b r for which mapping of consecutive elements of b p into consecutive elements of b r ( b p 1 b r 1 , , b p k b r k ) is a permutation of a set { b p 1 , , b p k } that can be decomposed into one disjoint cycle. Otherwise each sequence of paths identified by a disjoint cycle in the decomposition can generate a separate cycle. For k = 1 , b k L 0 e , b b is the desired permutation, and, for k > 1 , it is easy to see, that b k L 0 e , mappings b b z , where z [ k 1 ] , are the desired permutations.
From such block matrices k 0 , m A b , c , only entries k 0 , m a b , c d s , d s ¯ add to the number k T H C ( G ) , since they cover all remaining vertices on the shared wall between tiles T m and T 0 exactly once. Because of the introduced lexicographic order on sets k L i r , k R i r ,
s [ | k L 0 r | ] : d s ¯ = d | k L 0 r | + 1 s .
Hence, if k = 1 , b k L 0 e ,
k 0 , m a b , b d s , d s ¯ = k 0 , m a b , b d s , d | k L 0 r | + 1 s ,
and, if k > 1 , b k L 0 e , z [ k 1 ] ,
k 0 , m a b , b z d s , d s ¯ = k 0 , m a b , b z d s , d | k L 0 r | + 1 s
are values that contribute to k T H C ( G ) .
However, since there are k ! block matrices that calculate same cycles (ones that generate permutations over the same set), the total sum must be divided by k ! .  □
Remark 2. 
1. 
If k = 1 , for b k L 0 e , set
k 0 , m a b , b d s , d s ¯ | s [ | k L 0 r | ]
forms an anti-diagonal of block matrix k 0 , m A b , b .
2. 
If k > 1 , for b k L 0 e and z [ k 1 ] , set
k 0 , m a b , b z d s , d s ¯ | s [ | k L 0 r | ]
forms an anti-diagonal of block matrix k 0 , m A b , b z .
Using the above algorithm, some results from [18] can be recreated. In it, 2-tiled graphs are investigated.
Example 7 
(Counting traversing Hamiltonian cycles in 2-tiled graphs). For 2-tiled graphs, 1-traversing (denoted as zigzagging in [18]) and 2-traversing (denoted as traversing in [18]) Hamiltonian cycles may exist:
  • 1-traversing: The matrix k 0 , m A is a 2 × 2 block matrix, where each block is of dimension 2 × 2 :
    k 0 , m A 1 , 1 k 0 , m A 1 , 2 k 0 , m A 2 , 1 k 0 , m A 2 , 2 = k 0 , m a 1 , 1 1 , 1 k 0 , m a 1 , 1 1 , 0 k 0 , m a 1 , 2 1 , 1 k 0 , m a 1 , 2 1 , 0 k 0 , m a 1 , 1 0 , 1 k 0 , m a 1 , 1 0 , 0 k 0 , m a 1 , 2 0 , 1 k 0 , m a 1 , 2 0 , 0 k 0 , m a 2 , 1 1 , 1 k 0 , m a 2 , 1 1 , 0 k 0 , m a 2 , 2 1 , 1 k 0 , m a 2 , 2 1 , 0 k 0 , m a 2 , 1 0 , 1 k 0 , m a 2 , 1 0 , 0 k 0 , m a 2 , 2 0 , 1 k 0 , m a 2 , 2 0 , 0 .
    Then
    1 T H C ( G ) = k 0 , m a 1 , 1 1 , 0 + k 0 , m a 1 , 1 0 , 1 + k 0 , m a 2 , 2 1 , 0 + k 0 , m a 2 , 2 0 , 1 .
  • 2-traversing: The matrix k 0 , m A is a 2 × 2 block matrix, where each block is of dimension 1 × 1 :
    k 0 , m A 12 , 12 k 0 , m A 12 , 21 k 0 , m A 21 , 12 k 0 , m A 21 , 21 = k 0 , m a 12 , 12 ϵ , ϵ k 0 , m a 12 , 21 ϵ , ϵ k 0 , m a 21 , 12 ϵ , ϵ k 0 , m a 21 , 21 ϵ , ϵ .
    Then
    2 T H C ( G ) = 1 2 ! ( k 0 , m a 12 , 21 ϵ , ϵ + k 0 , m a 21 , 12 ϵ , ϵ ) = k 0 , m a 12 , 21 ϵ , ϵ .
Corollary 2. 
Let T be a finite family of tiles, and let G be a family of cyclizations of finite sequence of such tiles. There exists and algorithm that yields, for each graph G G , k min w s ( G ) , the number k T H C ( G ) . For a fixed set T , the running time of the algorithm is linear in the number of tiles (and hence vertices) of G.
Proof. 
For a fixed family of tiles, we precalculate matrices k i A (and so k i A ¯ ). The time complexity to compute the matrix k 0 , m A is O ( m ) and additional O ( 1 ) is needed to obtain the searched sum from it. □

4. Conclusions and Further Research

In this paper, we presented a solution to count traversing Hamiltonian cycles in tiled graphs. We accomplished it by introducing an extended matrix method from [18], where the crucial part was the identification of matrices k i A . Similarly as in [18] for 2-tiled graphs, in Corollary 2, we used the fact that, in a finite set of tiles, the generation of these matrices can be thought of as a constant problem, which resulted in that our algorithm’s running time is linear in the number of tiles (and hence vertices). In general, this is not true, so we now propose the following open problem:
Open problem. 
Find an (efficient) algorithm to generate block matrices k i A .
By definition, traversing Hamiltonian cycles are such that their intersection with the tile results in paths that start in one wall and end in another wall of the tile. Obviously, however, there are also types of Hamiltonian cycles such that their intersection with a tile also allows paths that start and end in the same wall of the tile (flanking Hamiltonian cycles as an example in 2-tiled graphs [18]). Therefore, we additionally propose the following open problems:
Open problem. 
Identify other types of Hamiltonian cycles in tiled graphs.
Open problem. 
Count other types of Hamiltonian cycles in tiled graphs.

Funding

This research was funded by Slovenian Research Agency (research project J1-2452).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Acknowledgments

I am grateful to Drago Bokal for his critical comments that encouraged me to improve the presentation of the paper.

Conflicts of Interest

The author declares no conflict of interest.

Appendix A

Table A1. Glossary of frequently used symbols.
Table A1. Glossary of frequently used symbols.
NotationDescription
k L i e Set of strings of left endvertices of length k (out of k i options), ordered lexicographically from smallest to largest. Used to model left-to-right transition modes. It is clear that | k L i e |   = k i k k ! .
k R i e Set of strings of right endvertices of length k (out of l i options), ordered lexicographically from smallest to largest. Used to model left-to-right transition modes. It is clear that | k R i e |   = l i k k ! .
ϵ An empty string.
k L i r Set of all binary strings of length k i k (for remaining k i k left wall vertices), ordered lexicographically from largest to smallest.
k L i r = { ϵ } , k = k i { 0 , 1 } k i k , otherwise .
Used to model the coverage of wall vertices with paths within current (bit value 1) or a neighboring tile (bit value 0). It is clear that | k L i r | = 2 k i k .
k R i r Set of all binary strings of length l i k (for remaining l i k left wall vertices), ordered lexicographically from largest to smallest.
k R i r = { ϵ } , k = l i { 0 , 1 } l i k , otherwise .
Used to model the coverage of wall vertices with paths within current (bit value 1) or a neighboring tile (bit value 0). It is clear that | k R i r | = 2 l i k .
x ¯ Denotes a bit string where all bits in x are flipped.
k i A A | k L i e |   ×   | k R i e | block matrix of form
k i A b 1 , c 1 k i A b 1 , c 2 k i A b 1 , c | k R i e | k i A b 2 , c 1 k i A b 2 , c 2 k i A b 2 , c | k R i e | k i A b | k L i e | , c 1 k i A b | k L i e | , c 2 k i A b | k L i e | , c | k R i e | .
k i A b p , c r For p [ | k L i e | ] , r [ | k R i e | ] , it is a | k L i r |   ×   | k R i r | matrix of form
k i a b p , c r d 1 , e 1 k i a b p , c r d 1 , e 2 k i a b p , c r d 1 , e | k R i r | k i a b p , c r d 2 , e 1 k i a b p , c r d 2 , e 2 k i a b p , c r d 2 , e | k R i r | k i a b p , c r d | k L i r | , e 1 k i a b p , c r d | k L i r | , e 2 k i a b p , c r d | k L i r | , e | k R i r | .
k i a b p , c r d u , e v For p [ | k L i e | ] , r [ | k R i e | ] and u [ | k L i r | ] , v [ | k R i r | ] , it represents the number of possible combinations in T i for k distinct paths covering all internal vertices that have ordered left wall endvertices b p and ordered right wall endvertices c r (defining paths b p 1 c r 1 , b p 2 c r 2 , , b p k c r k ), d u describing if remaining k i k left wall vertices are/are not part of any k paths and e v describing if remaining l i k right wall vertices are/are not part of any k paths.
k i A ¯ A | k L i e | × | k R i e | block matrix of form
k i A ¯ b 1 , c 1 k i A ¯ b 1 , c 2 k i A ¯ b 1 , c | k R i e | k i A ¯ b 2 , c 1 k i A ¯ b 2 , c 2 k i A ¯ b 2 , c | k R i e | k i A ¯ b | k L i e | , c 1 k i A ¯ b | k L i e | , c 2 k i A ¯ b | k L i e | , c | k R i e | .
k i A ¯ b p , c r For p [ | k L i e | ] , r [ | k R i e | ] , it is a | k L i r | × | k R i r | matrix of form
k i a b p , c r d 1 ¯ , e 1 k i a b p , c r d 1 ¯ , e 2 k i a b p , c r d 1 ¯ , e | k R i r | k i a b p , c r d 2 ¯ , e 1 k i a b p , c r d 2 ¯ , e 2 k i a b p , c r d 2 ¯ , e | k R i r | k i a b p , c r d | k L i r | ¯ , e 1 k i a b p , c r d | k L i r | ¯ , e 2 k i a b p , c r d | k L i r | ¯ , e | k R i r | .

References

  1. des Cloizeaux, J.; Jannik, G. Polymers in Solution: Their Modelling and Structure; Clarendon Press: Oxford, MS, USA, 1990. [Google Scholar]
  2. Kloczkowski, A.; Jernigan, R.L. Transfer matrix method for enumeration and generation of compact self-avoiding walks. I. Square lattices. J. Chem. Phys. 1998, 109, 5134–5146. [Google Scholar] [CrossRef]
  3. Jacobsen, J.L. Exact enumeration of Hamiltonian circuits, walks and chains in two and three dimensions. J. Phys. A Math. Theor. 2007, 40, 14667–14678. [Google Scholar] [CrossRef]
  4. Montoya, J.A. On the Counting Complexity of Mathematical Nanosciences. MATCH Commun. Math. Comput. Chem. 2021, 86, 453–488. [Google Scholar]
  5. Alahmadi, A.; Aldred, R.E.L.; de la Cruz, R.; Solé, P.; Thomassen, C. The maximum number of minimal codewords in long codes. Discret. Appl. Math. 2013, 161, 424–429. [Google Scholar] [CrossRef] [Green Version]
  6. Alahmadi, A.; Aldred, R.E.L.; de la Cruz, R.; Solé, P.; Thomassen, C. The maximum number of minimal codewords in an [n,k]-code. Discret. Math. 2013, 313, 1569–1674. [Google Scholar] [CrossRef]
  7. Alahmadi, A.; Aldred, R.E.L.; de la Cruz, R.; Ok, S.; Solé, P.; Thomassen, C. The minimum number of minimal codewords in an [n,k]-code and in graphic codes. Discret. Appl. Math. 2015, 184, 32–39. [Google Scholar] [CrossRef] [Green Version]
  8. Nishat, R.I.; Whitesides, S. Reconfiguring Hamiltonian Cycles in L-Shaped Grid Graphs. Graph-Theor. Concepts Comput. Sci. 2019, 21, 325–337. [Google Scholar]
  9. Liang, T.C.; Chakrabarty, K.; Karri, R. Programmable daisychaining of microelectrodes to secure bioassay IP in MEDA biochips. IEEE Trans. Very Large Scale Integr. (VLSI) Syst. 2020, 25, 1269–1282. [Google Scholar] [CrossRef]
  10. Tošić, R.; Bodroža-Pantić, O.; Kwong, Y.H.H.; Straight, H.J. On the number of Hamiltonian cycles of P4 × Pn. Indian J. Pure Appl. Math. 1990, 21, 403–409. [Google Scholar]
  11. Kwong, Y.H.H.; Rogers, D.G. A matrix method for counting Hamiltonian cycles on grid graphs. Eur. J. Comb. 1994, 15, 277–283. [Google Scholar] [CrossRef] [Green Version]
  12. Bodroža-Pantić, O.; Tošič, R. On the number of 2-factors in rectangular lattice graphs. Publ. L’Institut Math. 1994, 56, 23–33. [Google Scholar]
  13. Stoyan, R.; Strehl, V. Enumeration of Hamiltonian circuits in rectangular grids. J. Comb. Math. Comb. Comput. 1996, 21, 109–127. [Google Scholar]
  14. Bodroža-Pantić, O.; Pantić, B.; Pantić, I.; Bodroža-Solarov, M. Enumeration of Hamiltonian cycles in some grid graphs. MATCH Commun. Math. Comput. Chem. 2013, 70, 181–204. [Google Scholar]
  15. Bodroža-Pantić, O.; Kwong, H.; Doroslovački, R.; Pantić, M. Enumeration of Hamiltonian cycles on a thick grid cylinder—Part I: Non-contractible Hamiltonian cycles. Appl. Anal. Discret. Math. 2019, 13, 28–60. [Google Scholar] [CrossRef] [Green Version]
  16. Bodroža-Pantić, O.; Kwong, H.; Dokić, J.; Doroslovački, R.; Pantić, M. Enumeration of Hamiltonian cycles on a thick grid cylinder—Part II: Contractible Hamiltonian cycles. Appl. Anal. Discret. Math. 2022, 16, 246–287. [Google Scholar] [CrossRef]
  17. Đokić, J.; Doroslovački, K.; Bodroža-Pantić, O. A Spanning Union of Cycles in Thin Cylinder, Torus and Klein Bottle Grid Graphs. Mathematics 2023, 11, 846. [Google Scholar] [CrossRef]
  18. Vegi Kalamar, A.; Žerak, T.; Bokal, D. Counting Hamiltonian Cycles in 2-Tiled Graphs. Mathematics 2021, 9, 693. [Google Scholar] [CrossRef]
  19. Fernandes, C.G.; Hernández-Vélez, C.; de Pina, J.C.; Ramírez Alfonsín, J.L. Counting Hamiltonian Cycles in the Matroid Basis Graph. Graphs Comb. 2019, 35, 539–550. [Google Scholar] [CrossRef] [Green Version]
  20. Liu, X.; Wang, Z.; Yu, X. Counting Hamiltonian cycles in planar triangulations. J. Comb. Theory Ser. 2022, 155, 256–277. [Google Scholar] [CrossRef]
  21. Ferber, A.; Hardiman, L.; Mond, A. Counting Hamilton Cycles in Dirac Hypergraphs. Combinatorica 2023, 1–16. [Google Scholar] [CrossRef]
Figure 1. Possible combinations for 1 a 1 , 2 1 , 10 .
Figure 1. Possible combinations for 1 a 1 , 2 1 , 10 .
Mathematics 11 02650 g001
Figure 2. Possible combinations for 2 a 21 , 23 ϵ , 1 .
Figure 2. Possible combinations for 2 a 21 , 23 ϵ , 1 .
Mathematics 11 02650 g002
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Vegi Kalamar, A. Counting Traversing Hamiltonian Cycles in Tiled Graphs. Mathematics 2023, 11, 2650. https://doi.org/10.3390/math11122650

AMA Style

Vegi Kalamar A. Counting Traversing Hamiltonian Cycles in Tiled Graphs. Mathematics. 2023; 11(12):2650. https://doi.org/10.3390/math11122650

Chicago/Turabian Style

Vegi Kalamar, Alen. 2023. "Counting Traversing Hamiltonian Cycles in Tiled Graphs" Mathematics 11, no. 12: 2650. https://doi.org/10.3390/math11122650

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop