Manuscript Offprint
arXiv:2611.00364Hamiltonian Cycle Construction in Rectangular Grid Graphs with Three-Stacked Triangular Holes
1 Introduction
Hamiltonian cycles are a fundamental concept in graph theory. Given a graph, the Hamiltonian cycle problem asks whether there exists a cycle that visits every vertex exactly once. In general, determining the existence of a Hamiltonian cycle is NP-complete, and this hardness persists even for grid graphs [4]. However, certain structured classes of grid graphs admit efficient algorithms. For example, Hamiltonian cycles in solid grid graphs can be found in polynomial time [13], while rectangular grid graphs admit simple constructions based on their dimensions and parity properties.
The problem becomes more challenging when holes are introduced into the grid. Removing vertices changes the structure of the graph and may create narrow regions or additional constraints on how a Hamiltonian cycle can be constructed. Nevertheless, several structured grid graphs with holes remain tractable. Previous work has developed efficient algorithms for rectangular grid graphs with rectangular holes [7,8], as well as C-shaped and L-shaped grid graphs [5,6].
A common approach in these studies is to decompose the original graph into smaller, more structured subgraphs. Hamiltonian paths or cycles are first constructed within individual subgraphs and then connected to obtain a global solution. This approach takes advantage of the known structural properties of rectangular grid graphs and reduces the difficulty of constructing Hamiltonian cycles in more complex geometries. However, the decomposition must be chosen carefully: the existence of Hamiltonian cycles within individual subgraphs does not necessarily guarantee that they can be combined into a Hamiltonian cycle of the entire graph.
In this paper, we study Hamiltonian cycles in rectangular grid graphs with a triangular hole removed. Unlike rectangular holes, the triangular structure introduces different geometric and parity constraints across its layers, making the construction of a global Hamiltonian cycle more complicated. The main contribution is a constructive algorithm for determining and building Hamiltonian cycles in rectangular grid graphs with a triangular hole, when such cycles exist.
Geometry-driven construction. The first approach is based on the geometry of the triangular hole. Depending on the relative position of the hole and the outer boundary, we distinguish between small-hole and large-hole configurations.
For small holes, the construction proceeds by finding a Hamiltonian path in a reversed triangular region, extending the path through a surrounding rectangular region, and combining the resulting structure with Hamiltonian cycles in the remaining graph.
Large-hole configurations require additional constructions because some of the surrounding rectangular regions may disappear or become too narrow to support the same operations.
Rectangular-decomposition construction. The second approach partitions the graph into a collection of rectangular subgraphs.
If every rectangular component has an even number of vertices, a Hamiltonian cycle can be constructed locally within each component.
The local cycles can then be merged whenever suitable pairs of adjacent cycle edges exist.
If some components contain an odd number of vertices, the original partition cannot directly support a collection of local Hamiltonian cycles. We therefore investigate alternative partitions and boundary adjustments that transform the components into even-sized rectangles.
The two approaches provide different strategies for addressing the same problem. The geometry-driven approach constructs Hamiltonian paths and cycles based on the specific structure of the triangular hole, but requires extensive case analysis when the hole approaches the outer boundary. The rectangular-decomposition approach aims to provide a more systematic alternative by reducing the problem to constructing and merging Hamiltonian cycles in rectangular subgraphs. While the first approach focuses on explicit geometric constructions, the second investigates whether parity-based repartitioning can simplify the construction and reduce the need for geometry-specific cases. The completeness of both approaches remains under investigation.
1.2 Organization
Section 2 discusses related work. Section 3 defines the graph family. Section 4 introduces rectangular Hamiltonian-cycle constructions and cycle-merging operations. Section 5 presents the geometry-driven construction. Section 6 develops the rectangular-decomposition approach. Section 8 discusses the remaining theoretical questions.
2 Related Work
The Hamiltonian path problem in grid graphs has been extensively studied due to both its theoretical significance and its applications in problems such as the traveling salesman problem (TSP) [1,11], robotic coverage, and routing in discrete environments. In these settings, a Hamiltonian path corresponds to visiting every location exactly once, making efficient constructions particularly important.
In their seminal work, Itai, Papadimitriou, and Szwarcfiter [4] proved that the Hamiltonian path (and cycle) problem is NP-complete for general grid graphs. At the same time, they showed that for rectangular grid graphs , the problem admits a complete characterization together with a linear-time algorithm. Their approach is based on bipartite coloring and forbidden configurations, providing both necessary and sufficient conditions and a constructive method for -Hamiltonian paths.
In addition, their analysis relies on the bipartite structure of grid graphs. In particular, for any grid graph (not necessarily rectangular), the graph is bipartite under the parity coloring of vertices.
As a consequence, if the total number of vertices is even, any Hamiltonian path must start and end at vertices of different colors. This parity condition serves as a fundamental necessary condition and will be used implicitly throughout our constructions.
Following this, Umans and Lenhart [13] studied solid grid graphs, i.e., grid graphs without holes, and showed that Hamiltonian cycles can be found in polynomial time. This result highlights that the presence of holes fundamentally changes the structure of the problem. From an application perspective, holes correspond to obstacles or unavailable regions, which significantly complicate path construction.
A major line of work focuses on grid graphs with structured holes, where algorithmic techniques are developed to preserve linear-time solvability. Keshavarz-Kohjerdi and Bagheri proposed linear-time algorithms for finding Hamiltonian -paths in rectangular grid graphs with a rectangular hole, covering both even-sized and odd-sized cases in [8] and [7]. Their algorithms extend the classical framework by introducing additional necessary conditions induced by the hole. The key technique is to decompose the graph into structured subgraphs, construct Hamiltonian paths within each component, and then combine them into a global solution through carefully designed connections.
Beyond rectangular holes, several works have explored other structured geometries with an emphasis on constructive algorithms. In [5], the authors studied C-shaped grid graphs and presented a linear-time algorithm based on identifying separable substructures and recursively merging Hamiltonian paths. Similarly, in [6], L-shaped grid graphs were analyzed, and a linear-time construction algorithm was given. These approaches share a common strategy: partition the graph into simpler components, construct Hamiltonian paths or cycles in each part, and combine them via well-defined merging operations.
More recent work continued this direction by considering increasingly complex hole configurations. For example, rectangular grid graphs with an L-shaped hole can be handled by partitioning the graph into multiple rectangular and C-shaped subgraphs, constructing Hamiltonian cycles in each component, and merging them via parallel edges [12]. Similarly, algorithms for Hamiltonian cycles in C-shaped and related grid graphs have been refined using decomposition and merge-based techniques [9]. These divide-and-conquer algorithms demonstrate that efficient constructions are possible when the graph can be reduced to a bounded number of structured components.
In addition to standard grid graphs, related models such as supergrid graphs and other generalized grid structures have also been studied. For example, Hamiltonian properties of supergrid graphs and their subclasses have been investigated in [2,3], further demonstrating how structural constraints enable efficient algorithms even in extended settings.
Existing work is largely tailored to specific global shapes of the graph or the hole. The algorithms are typically designed for particular configurations, and their correctness depends on detailed case analyses corresponding to those shapes. In particular, the structure of the Hamiltonian path itself is often implicit in the construction. Our work will also follow the same strategy.
Even in the classical rectangular grid graph , although the existence problem is fully solved, there has been limited investigation into finer structural patterns. In particular, the relationship between the parity of m and n, the feasible positions of s and t, and the resulting shape of the Hamiltonian path has not been systematically analyzed. Understanding these patterns can lead to more explicit constructions and enable techniques such as systematic rectangular cutting, which simplifies the problem and is particularly useful in large-scale applications.
Furthermore, prior work on grid graphs with holes primarily focuses on single, well-structured hole shapes, such as rectangular, C-shaped, or L-shaped holes. There has been relatively little analysis of more complex holes that can be viewed as compositions of simpler components. Existing algorithms rely on global decomposition tailored to specific shapes. A compositional framework that analyzes how local structures interact will be needed to handle more complex holes.
3 Setup of the Triangular Hole

Figure 1: A triangle hole inside a rectangle grid graph
We will now formally introduce and define the setup for the triangular hole inside of the rectangular grid graph, which we construct by stacking L-shape holes, shown in Figure 1 and 2. Note that we will work with right triangular hole, which reduces the analysis complexity. However, this doesn't mean that non-right triangular hole is completely unreachable from our work, instead, it can be treated as two right triangle placed side by side. Hence, it would just be more case analysis. The right triangle is placed so that its legs lie along grid lines parallel to the coordinate axes. In particular, one leg is parallel to the x-axis and the other is parallel to the y-axis of the enclosing rectangle. For example, in Figure 1 for triangle , edge is parallel to the left edge of the outside rectangle and edge is parallel to the bottom edge.
In a rectangle grid graph, , where, WLOG, is the width and is the height, we define a triangle hole , where is the base of the triangle (the edge that is parallel to the bottom edge of the outer rectangle), and is the height, as shown in Figure 1. We set the following variables to represent the distance between two edges or vertices, which is the number of vertices in between: as the distance between the top edge of the rectangle () and the apex of the triangle (); as the distance between the triangle's base () and the rectangle's bottom edge (); is the distance between the triangle's apex () and the right edge of the rectangle (); is the distance between the right end point of the base () and right edge of the rectangle (); and is the distance between the vertical leg of the triangular hole () and the left edge of the outer rectangle (). Note that triangle is not necessarily centered in the rectangle grid graph, i.e., it is not necessary for to be equal to or for to be equal to .
3.1 The Tall Triangle
Given a rectangle grid graph with a triangle hole , if we add the requirement that: each layer of the triangle has constant width , except for the bottom layer, which is wider with width , as long as it fits inside the rectangle. We call the triangle represented by a grid graph holding the above property a tall triangle. A tall triangle is equivalent to an L-shape, shown in Figure 2a, where the height for the horizontal part is , and the width for the vertical part is .
3.2 Tall Triangles Stacking

m
(a)

m
(b)

m
(c)
Figure 2: Convert several tall triangle holes into a right triangle hole
Now, we can stack several L-shape holes together by arranging the bottom rows layer by layer from the widest to the thinnest, as shown in Figure 2b. In addition, we require that all L-shape holes have the vertical column (completely or partially) aligned with or right next to each other. This is equivalent to each L-shape hole holding the following fact relatively to the hole right below it : and . Note that since the L-shapes are stacked from the widest to the thinnest, the spaces between the L-shapes stack and right edges decrease gradually from top to bottom, i.e, , as shown in Figure 2c.
It is not difficult to see that an arbitrary right triangle can be obtained by stacking a specific sequence of tall triangles. Given this construction, we define as the width of the highest column, which is also equal to the total contribution of the corresponding widths from all L-shaped components, as shown in Figure 2c. Let d denote the horizontal distance between this column and the left boundary of the outer rectangle. We define as the height of the vertical column, which is also the height of the topmost L-shaped component.
The parameters , , , and are defined analogously to the tall triangle case. Let denote the set of horizontal distances from the base to the rightmost edge of each L-shaped component. Note that the widths are defined slightly differently. Specifically, is the base width of the L-shaped component (ordered from top to bottom), defined as the horizontal distance between the leftmost column of the bottom L-shaped hole and the right edge of the vertical segment of the L-shape. For example, corresponds to the width of the second L-shape shown in Figure 2c.
3.3 Three-stacked Right Triangular Hole
We focus our work on right triangular holes, and specifically on three-stacked triangular hole, which is constructed by stacking three L-shaped holes from bottom to top. Without loss of generality we assume that the two legs lie along the left and bottom boundaries of the rectangle, as shown in Figure 2.
The placement of the right triangular hole is determined by the parameters , which describe the horizontal distances on the right, the offset d from the left boundary, the vertical distances a and b, and the width and height parameters for each L-shaped component, namely and .
4 Definitions and Preliminary Supporting Theorems
In this section, we introduce several definitions and preliminary supporting results that will be useful for explaining the constructions and algorithms presented in later sections. These supporting results and the rectangular classification provide the building blocks for our constructions.
A grid graph is a finite, node-included subgraph of the infinite graph consisting of all points with integer coordinates in the plane, where two vertices are connected if and only if they are at Euclidean distance 1 from each other [4,13]. A (grid) graph has a Hamiltonian path between starting vertex s and ending vertex t if and only if there exists a path that visits each vertex of the graph exactly once from s to t. A Hamiltonian cycle is such a path that returns to s after visiting all vertices exactly once. A rectangular grid graph, , is a rectangle shape of grids, where m is the number of columns and n is the number of rows.
We will also use a basic structural property of grid graphs that follows from their bipartite nature. By coloring each vertex according to the parity of , every grid graph admits a bipartition in which each edge connects vertices of opposite colors [4]. As a consequence, the endpoints of any Hamiltonian path are constrained by the parity of the graph.
Lemma 4.1. Let G be any grid graph with an even number of vertices. If there exists a Hamiltonian path between vertices s and t, then s and t must lie in different bipartition classes, as s and t in Figure 3a and 3b, which lie in different classes.

(a)

(b)
Figure 3: s and t are denoted by the solid black vertices
We use a Cartesian coordinate system to index the vertices of . The origin is placed at the leftmost vertex of the top row, so the top-left vertex has coordinate . The x-coordinate increases from left to right, and the y-coordinate increases from top to bottom. Under this convention, the bottom-right vertex of has coordinate . For example, in the rectangle with width 4 and height 2 as shown in Figure 3a, the top left vertex is , the bottom left vertex is , and vertex a is .
We first consider the simplest nontrivial case, the 2-rectangle grid graph, , i.e. a rectangle with 2 rows, which serves as a fundamental building block for understanding more general constructions. The following lemma describes the basic strategies for constructing Hamiltonian paths depending on the relative positions of s and t. We state the following supporting proposition.
Proposition 4.2. For a 2-rectangle grid graph to have a valid Hamiltonian path:
-
s and t are in the same column. Then . A Hamiltonian path exists between s and t and we can find it by going horizontally and completing a single sideways U, as shown in Figure 3a.
-
s and t are not in the same column. Then , and we need to go vertically and perform successive U-turns, as shown in Figure 3b;
The previous lemma characterizes constructive strategies in the feasible cases. We now describe conditions under which such a construction is not possible.
Proposition 4.3. The 2-rectangle grid graph does not have a valid Hamiltonian path between s and t, when s and t are in different columns and either:
-
s and t are not in the same row and m is even, as shown in Figure 4a.
-
s and t are in the same row and m is odd, as shown in Figure 4b.

(a)

(b)
Figure 4

(a)

(b)
Figure 5
We now extend these observations from 2-rectangles to more general rectangular grid graphs. The following lemma illustrates standard construction strategies when the height n is even, which will be used as a basis for later constructions.
Lemma 4.4. For any rectangle , if n is even, the Hamiltonian Path can be created by:
-
if is the top left vertex and is bottom left vertex, then , , and is even, we can construct a Hamiltonian path by using strategy 1, go horizontally, then turn when necessary, as shown in Figure 5a.
-
if and , we can construct one by using strategy 2, go vertically, then turn when necessary, as shown in Figure 5b.
We observe that for a rectangular grid graph , different parity combinations of and may lead to different acceptable starting and ending vertex combinations. Hence, given an arbitrary rectangular grid graph, , we proposed a classification method into 10 categories based on the parity of its width and height, as shown in Equation 1. Note that, apart from those purely based on parity, there are also size-induced cases, i.e. , and . These special cases occur when or is 2 or 3, and there may not be enough space to turn with so few vertices.
For example, Figure 5a is a rectangle with 4 columns and 4 rows, , and are both even and greater than 2. Hence, Figure 5a is . As shown in Figure 4b, , is a rectangle with 5 columns and 2 rows, which makes it fall into .
4.1 Constructing a Hamiltonian Cycle
4.1.1 Even-sized Rectangles
Inspired by the snake-based construction of Lewis et al. [10], we describe an alternative explicit procedure for constructing Hamiltonian cycles in even-sized rectangular grid graphs. We first introduce a basic construction that will be used repeatedly in later sections. Consider an even-sized rectangular grid graph , where m denotes the number of columns and n denotes the number of rows. Since is even-sized, at least one of m and n is even. Therefore, if necessary, we rotate the rectangle by so that the number of vertices in each row is even. After this rotation, we assume that m is even.
We use the coordinate system in which is the upper-left vertex, the -coordinate increases from left to right, and the -coordinate increases from top to bottom. Thus, the upper-right vertex is and the bottom-right vertex is .
As shown in Fig. 6, a Hamiltonian Cycle can be constructed in the following way: Starting from , we first traverse the entire top row from left to right and then move downward along the rightmost column. After reaching the bottom boundary, we repeatedly move one column to the left and traverse that column in the opposite vertical direction. In this way, the path forms a sequence

Figure 6: The rectangular cycle construction for . The top row is covered first; alternating vertical traversals stop below it, and the reserved leftmost column closes the cycle.
of alternating vertical traversals connected by single horizontal edges. The process continues until every vertex is covered, after which the path returns to through the leftmost column.
The construction is formally described in Algorithm 1.
Algorithm 1: Hamiltonian Cycle in an Even-Sized Rectangular Grid Graph
Input: An even-sized rectangular grid graph , with
Output: A Hamiltonian cycle of
Rotate the rectangle by , if necessary, so that m is even;
Start at and traverse the top row to ;
Move down the rightmost column to ;
for do
Move left to column j;
if j is even then
| Traverse upward to , stopping below the visited top row;
else
| Traverse downward to ;
Move left to ;
Traverse the leftmost column upward and close the cycle at ;
Return the cycle, rotating it back if the input was rotated;
Theorem 4.5. For every even-sized rectangular grid graph with , Algorithm 1 constructs a Hamiltonian cycle.
Proof. Since is even-sized, at least one of m and n is even. Therefore, after rotating the rectangle if necessary, we may assume that m is even. Algorithm 1 first covers the entire top row. It then traverses the remaining columns alternately downward and upward, moving one column to the left after each vertical traversal. Each upward traversal stops at row 1, so the already visited top row is not revisited. The leftmost column is reserved for closing the cycle. Since m is even, the traversal of column 1 ends at its bottom vertex, adjacent to .
Each column is traversed only once, and the already-covered top-row vertices are not revisited. Therefore, every vertex of is visited exactly once. Finally, the algorithm moves upward along the leftmost column and returns to the starting vertex . Hence, the resulting path is a cycle that contains every vertex exactly once, and is therefore a Hamiltonian cycle.
4.1.2 Odd-sized Rectangles
The previous theorem shows that Algorithm 1 constructs a Hamiltonian cycle whenever the rectangular grid graph is even-sized. We now consider the remaining case, when the rectangular grid graph has an odd number of vertices. In this case, a Hamiltonian cycle is impossible due to the bipartite structure of grid graphs [4].
Theorem 4.6. Let be a finite grid graph. If has an odd number of vertices, then does not admit a Hamiltonian cycle.
Together, Theorems 4.5 and 4.6 imply that a rectangular grid graph , with , has a Hamiltonian cycle if and only if is even. We will need to focus on odd-sized rectangular grid graphs for later larger grid's Hamiltonian Cycle construction.
4.2 Connecting Two Hamiltonian Cycles
The previous subsection gives a fixed construction of a Hamiltonian cycle for every even-sized rectangular grid graph. We now consider how two such cycles can be combined when the corresponding rectangular grid graphs are adjacent. This operation will later allow us to construct Hamiltonian cycles in larger grid graphs by decomposing them into rectangular subgraphs.
Definition 4.7. Let and be two vertex-disjoint rectangular grid graphs. We say that and are connected if there exist at least two consecutive boundary vertices of that are respectively adjacent to two consecutive boundary vertices of .
The portions of the boundaries of and that face each other will be called their connecting boundaries.
For a Hamiltonian cycle constructed by Algorithm 1, the edges along a boundary have one of two forms. On three of the four boundaries, all consecutive boundary vertices are joined by the Hamiltonian cycle; we call such a boundary a straight boundary. On the remaining boundary, the cycle contains alternating boundary edges: the first two vertices are joined, the next pair is not, the following pair is joined, and so on. We call this an alternating boundary.
Thus, when two rectangular grid graphs are connected, their connecting boundaries fall into one of the following three cases:
-
a straight boundary is adjacent to an alternating boundary;
-
a straight boundary is adjacent to a straight boundary;
-
an alternating boundary is adjacent to an alternating boundary.
Theorem 4.8. Let and be two connected even-sized rectangular grid graphs, and let and be the Hamiltonian cycles constructed in and , respectively, by Algorithm 1. Assume that the common interface contains an edge of each alternating connecting boundary involved. In the alternating-alternating case, also assume that the two alternating patterns are aligned as described below. Then there exist edges and on the two connecting boundaries such that are edges of the full grid graph. In other words, the two cycle edges are parallel and adjacent across the connecting boundary.
Proof. Let the connecting boundaries of and be considered.
If either connecting boundary is a straight boundary, then every pair of consecutive vertices on that boundary is joined by an edge of its Hamiltonian cycle. The connecting interface contains consecutive vertices that are adjacent across the two rectangles. If the other boundary is alternating, the interface assumption ensures that at least one of its used boundary edges lies within this interface. The straight boundary contains the corresponding parallel edge.
If the other boundary is also straight, those two vertices are joined by a cycle edge immediately. If the other boundary is alternating, we choose the corresponding consecutive pair for which the alternating boundary edge belongs to the Hamiltonian cycle. Hence, in both the straight–straight and straight–alternating cases, a pair of parallel cycle edges can be found.
It remains to consider the alternating-alternating case. For this case, we restrict our attention to two rectangles whose connecting boundaries are aligned; equivalently, the rectangles share the same left, right, top, or bottom outer boundary. Without loss of generality, assume that they share the same left boundary. Because Algorithm 1 produces the same alternating pattern from the same aligned endpoint, the alternating cycle edges on the two connecting boundaries occur in matching positions. Thus, there exists a pair of adjacent parallel cycle edges, one belonging to and the other to .

Straight-alternating

Straight-straight

Alternating-alternating
Figure 7: The three connecting-boundary cases. Blue segments are a compatible pair of cycle edges; dashed segments are grid edges across the interface. Alternating patterns must contain matching edges within the common interface.
Therefore, under the stated interface and alignment conditions, such a pair of parallel cycle edges can be found in all three cases.
Once such a pair of parallel cycle edges has been found, the two Hamiltonian cycles can be merged into a single Hamiltonian cycle using the merge operation described in [12].
Suppose the two parallel edges are and , where is adjacent to and is adjacent to in the original grid graph. We remove the two edges and , and instead add the two connecting edges and .
Removing one edge from each Hamiltonian cycle turns each cycle into a Hamiltonian path. The two newly added edges connect the endpoints of these two paths and therefore form a single cycle containing all vertices of both rectangles exactly once. Hence, the resulting cycle is a Hamiltonian cycle of the combined grid graph.
This merging operation is illustrated in Figure 8.

(a) Before merging

(b) After merging
Figure 8: Merging two Hamiltonian cycles. In (a), and are parallel cycle edges, while the dashed edges indicate adjacency between the two rectangular grid graphs. In (b), the edges and are removed and replaced by and , producing one larger Hamiltonian cycle.
Conclusion. We have now shown how to construct a Hamiltonian cycle in any even-sized rectangular grid graph, and how to merge two rectangular Hamiltonian cycles when compatible boundary edges are available. Therefore, whenever a larger grid graph can be decomposed into connected even-sized rectangular subgraphs, we may construct a Hamiltonian cycle within each rectangle and repeatedly apply the merging operation, provided that a compatible edge pair remains available at every step, to obtain one Hamiltonian cycle for the entire graph.
This observation allows us to return to our original setting of a rectangular grid graph with a triangular hole. Rather than constructing the Hamiltonian cycle globally, we will separate the remaining grid into a collection of rectangular subgraphs and view the full graph as a set of rectangles connected along their boundaries. For every even-sized rectangle, the construction from Algorithm 1 can be applied directly, and the resulting cycles can be combined using the merging operation established above.
The only rectangles that require additional treatment are odd-by-odd rectangles, since these subgraphs are odd-sized and therefore do not admit Hamiltonian cycles by themselves. In Section 6, we define how the larger grid graph is separated into rectangular subgraphs. We then analyze the possible appearances of odd-by-odd rectangles and develop separate constructions for handling them.
5 Geometry-Driven Hamiltonian Cycle Construction
We present an algorithm for constructing the Hamiltonian cycle in a rectangular Grid Graph with a right triangular hole if such a cycle exists. In general, there are two cases: if there is enough space around the hole, we construct the Hamiltonian cycle by generating a Hamiltonian Path that covers the complementary reversed triangle in the smallest rectangle that contains the triangular hole, and then connect it to the Hamiltonian cycle in the outer grid; if the hole is tightly bounded by the rectangular grid graph, i.e. the path of the Hamiltonian Cycle is constrained because the space is too narrow, then a Hamiltonian cycle's construction is determined by each boundary variables' value, i.e. .
5.1 Case Determination
Given a rectangular Grid Graph with a 3-stacked right triangular hole, shown in Figure 9a, to construct a Hamiltonian cycle if one exists, we want to construct the path for the irregular part of the graph first (the shaded area in Figure 9a), then find a way to connect it to the rest of the graph, if there is enough space to do so. Therefore, given such a Grid Graph, we need to first determine if there is enough space to do so. We define the following criteria: if , , , and , then there is enough space to build the irregular part first and then connect it to the whole grid graph. We call this the small hole case. Otherwise, if , , , or , as long as any of these holds, we will need to construct the Hamiltonian cycle globally, which we will call the large hole case, as shown in Figure 9b. We next present the constructions for these two cases.
5.2 The Small Hole Case
For the small hole case, as mentioned above, we construct a Hamiltonian Cycle for the inner irregular part, denoted as the red shadowed area in Figure 10a, and a Hamiltonian Cycle for the outer part, denoted as the green shadowed area in Figure 10a, and then connect those two together. We first construct the Hamiltonian Path for the irregular part, i.e., the reversed right rectangle

(a) Rectangular Grid Graph with 3-stacked Right Triangular Hole

(b) Large Hole Case When
Figure 9
that forms the minimal axis-aligned rectangle determined by the legs of the triangular hole, but with two vertices up and one column extended to the right, labeled as in Figure 10b.
We will construct the Hamiltonian Path of depending on the cases of the three-stacked subgraph between and , which is the leftmost vertex in the second row of and the rightmost vertex in the last row of , respectively, and then connect it to the outer grids. In order to better explain the algorithm for constructing a Hamiltonian Cycle under the small hole case, we will use an example to show how this works step by step in each subsection as we present the algorithm.
5.2.1 Reversed Right Triangle
In this section, we will explain the construction of the Hamiltonian Path in the complementary reversed right triangle, i.e., in Figure 10b (the shaded subgraph). We can also view this as three rectangles stacked together as shown in Figure 10c, where from top to bottom, , and have and as their widths and heights. Since is a reversed three-stacked triangle, we require that the width strictly decreases from top to bottom, i.e .
Note that in order to explain the structure of this three-stacking grid, we will describe each vertex using local coordinates, where represent the leftmost vertex on the top row of the subgraph , and represents the rightmost vertex of the bottom row of . We may also use a more local representation that use the information of each rectangle, i.e., represents the rightmost column of the topmost rectangle, , and represents the leftmost column of the middle rectangle, .
The main difficulty of constructing a Hamiltonian path in lies in coordinating the local paths across the stacked rectangles. While each rectangle individually admits Hamiltonian paths under appropriate boundary conditions, the vertical stacking imposes additional constraints: the

(a)

(b)

(c)
Figure 10: Rectangular Grid Graph with 3-stacked Right Triangular Hole
endpoint of one rectangle must coincide with the starting point of the next. Thus, feasibility is determined not only by local structure, but also by the compatibility of endpoints across layers.
From the case classification of the rectangular grid graphs, the existence of a Hamiltonian path between boundary vertices is governed primarily by parity conditions, which partition the rectangles into two classes and . Consequently, the problem reduces to selecting starting vertices whose x-coordinates satisfy these parity constraints while ensuring consistent alignment between adjacent rectangles. As what is described in algorithm 2, it systematically determines such starting positions based on the case type of each rectangle, thereby guaranteeing that the resulting local paths can be composed into a global Hamiltonian path.
Given the placement and property of in the grid graph, we have the following restriction for our Hamiltonian path construction in addition to the three-stacked setup: the starting vertex must lie on the bottom left of , , and the ending vertex is , which is the rightmost vertex on the bottom row of . Given those three rectangles, the following should hold: by design, , , , , and .
In order to construct a Hamiltonian Path between the desired and in the grid graph , we proposed the following algorithm, which clearly identifies a way to construct a Hamiltonian Path. As shown in the algorithm 2, , the starting vertex's x-coordinate is assigned clearly for all possible cases and y-coordinate can be computed simply, since the starting vertex of each rectangle stacked in this reversed right triangle always lies on the first row of each rectangle, which allows us to always find the starting vertex for each rectangle. The ending vertex will just be the vertex that connects to the starting vertex of the rectangle below, i.e., is right above , is right above , and is the rightmost vertex in the last row of the . Note that the algorithm is only concerned with assigning the x-coordinates of the starting vertices because the y-coordinates can be easily inferred, which is simply the top most row and bottom most row shown in each rectangle. Therefore, since the three starting vertices can always be found for all possible cases with some provable exceptions, i.e., all different stacking combinations of the three rectangles, a Hamiltonian path can always be constructed within .
Algorithm 2: Construct Hamiltonian Path in Reversed Right Triangle
Input: , and
Output: the x-coordinates of the starting vertices
;
;
if then
if , and is odd then
// Not exist I
else if is even, is odd, and then
// Not exist II
else if is odd, and is even then
// Subcase I
;
if then
else
else if is even, is odd, is odd, and is odd then
// Not exist II
else if is odd is odd then
// Subcase II
else
if then
else
else
if is odd, is odd, is even, and is odd then
// Not exist II
else
if then
else

(a) Classify Rectangle

(b) Endpoint Matching

(c) Generate Paths

(d) Connect Paths
Figure 11: An example of a rectangular grid graph with a small three-stacked right-triangular hole
Example We will use the example shown in Figure 11 to explain this algorithm, where and . As shown in Figure 11a, the reversed triangle part, is denoted via the orange box, which is a combination of three stacked rectangular subgraphs, , and as denoted. For those three rectangles, , and , based on the parity of width and height, is categorized as , is categorized as , and is categorized as . Then, according to Algorithm 2, as shown in Figure 11b, we can find the positioning for , and . Between each pair of starting vertex and ending vertex, a Hamiltonian path can be found within each rectangle as shown in Figure 11c. Then complete the paths by connecting the ending vertex of the rectangle above to the starting vertex of rectangle below, i.e. to , and to , as shown in Figure 11d. Therefore, we found a Hamiltonian path within the reversed right triangle for this example grid graph.
5.2.2 Bounding Rectangle
We first define a bounding rectangle that contains the entire three-stacked triangular hole. Specifically, this rectangle extends the hole by one column to the left and right, one row downward, and two rows upward. This bounding region is illustrated as the red rectangle in Figure 10b.
Since , which is one column wider than the protruding part of the base L-shape as shown in Figure 10b, we can connect to the vertex at the lower-right corner of the rightmost vertex of the triangular hole, i.e., , which covers in Figure 12a. Similarly, and can be covered in the same manner. It remains to connect the Hamiltonian path constructed within the inner region to the outer portion of the grid.
Example Using the same grid graph example, as shown in 12b: We complete the Hamiltonian Cycle for the minimal rectangular grid containing the three-stacked right triangular hole by connecting the starting vertex s and ending vertex t together via the thin U-shaped pathway.
5.2.3 Outer Grids
At this point, we have constructed a Hamiltonian cycle within the inner region , which forms a minimal rectangular grid containing the three-stacked right triangular hole. To obtain a Hamiltonian cycle for the entire grid graph, it remains to construct a Hamiltonian cycle for the outer region , as illustrated in Figure 13a, and then connect the two cycles together.

(a) , and structure

(b) Example of HP in the Bounding Rectangle
Figure 12
The construction of Hamiltonian cycles in the outer grids follows from existing results on rectangular grid graphs with rectangular holes. In particular, prior work has shown that rectangular grid graphs with rectangular holes admit linear-time algorithms for constructing Hamiltonian paths and cycles under appropriate conditions [7,8]. These results allow us to determine the Hamiltonian cycle structure of the outer region, since it can be viewed as a rectangular grid with a structured missing subgraph.
Furthermore, recent work on grid graphs with L-shaped holes adopts a divide-and-conquer approach: the graph is partitioned into several rectangular subgraphs, Hamiltonian cycles are constructed locally, and then combined using parallel edges [12]. In particular, two Hamiltonian cycles can be merged into a single cycle by removing a pair of parallel edges and reconnecting them across the boundary, resulting in a larger Hamiltonian cycle. This merge operation provides a systematic way to connect disjoint cycles.
Following this approach, we select an edge from the inner cycle and a corresponding parallel edge from the outer cycle . These edges must be adjacent: vertically aligned if they are horizontal edges, and horizontally aligned if they are vertical edges. By removing these two edges and reconnecting their endpoints across the boundary, the black edges shown in Figure 13a, we merge the inner and outer cycles into a single Hamiltonian cycle covering the entire graph.
This completes the construction for the small hole case.
Example Figure 13 shows the example of how to connect the inner Hamiltonian Cycle to the outer Grids. Given two Hamiltonian Cycles, one for the inner subgraph, one for the outer subgraph, we can find two parallel edges that are horizontally aligned, denoted red in Figure 13b. We now remove these two edges and reconnect their endpoints vertically, as shown in Figure 13c and 13d respectively.
5.3 The Large Hole Case
We organize the large-hole analysis by the boundary conditions , , , or .

(a) Subgraphs

(b) Two Parallel Edges

(c) Disconnect

(d) Reconnect Vertically
Figure 13: An Example: Connect to Outer Grids
These are exactly the situations in which at least one of the four complementary boundary regions of the hole becomes too thin or disappears entirely. As a result, the usual Hamiltonian cycle/path construction is no longer fully flexible: at least one side of the graph cannot be used as an ordinary transit corridor.
In the regular cases, the construction typically allows the cycle to pass through one side of the graph, continue to another subgraph, and later reconnect through a different side. In contrast, in the large-hole cases, one side is constrained. Therefore, the construction must be modified so that the cycle does not rely on repeated traversal across that constrained side. Instead, one must first determine which side is limited, and then arrange the cycle so that the corresponding region is covered in a prescribed manner and merged with the rest of the graph through the remaining unconstrained sides.
5.3.1 Sub Case I:
When , the right complementary side is constrained. In particular, the right side can no longer serve as a full connecting corridor between the upper and lower parts of the graph. Thus, the usual construction—which passes through the upper-right part, continues along the right side, and then connects directly to the lower part—is no longer available.
Instead, the construction must avoid relying on the right side as a transit region. The upper-right (shaded area in Figure 9a) remaining part must be covered and then merged back into the left/main portion of the graph, after which the cycle can continue toward the lower part. In other words, the traversal must return from the right toward the left, rather than using the right boundary as a direct channel from top to bottom.
Under this condition, we identified the following sub-cases, which we can either prove that a Hamiltonian path doesn't exist or construct a Hamiltonian path. We divide the analysis into three main subcases, one extreme case and two regular cases based on the parity of other parameters, i.e. , and . As shown below and in Figures 14 and 15, when are even, the Hamiltonian path construction will be slightly different based on the parity of and . The orange path indicates the nonexistence of a Hamiltonian Cycle under that specific subcase. A similarly pattern holds when or is odd, but we will not list it here due to the page limit.
| Condition (throughout, ) | Outcome or figure |
|---|---|
| or | No Hamiltonian cycle (Figure 14a) |
| The following rows assume are even. | |
| even | Figure 14b |
| odd, even, even | Figure 14c |
| odd, even, odd | No Hamiltonian cycle |
| odd, even, odd | Figure 14d |
| odd, even, even | No Hamiltonian cycle |
| odd, odd, odd | Figure 14e |
| odd, odd, even | No Hamiltonian cycle (Figure 15a) |
| odd, even, even, odd | No Hamiltonian cycle (Figure 15d) |
| odd, even, even, even | Figure 15e |
| odd, even, odd, odd | No Hamiltonian cycle (Figure 15c) |
| odd, even, odd, even | Figure 15b |
| , or odd | Detailed cases not included here |
Table 1: Parity cases for .

(a)

(b)

(c)

(d)

(e)
Figure 14: Construct Hamiltonian Cycle for Sub Case I of Large Hole Case

(a)

(b)

(c)

(d)

(e)
Figure 15: Construct Hamiltonian Cycle for Sub Case I of Large Hole Case
5.3.2 Sub Case II:
When , the upper complementary side is constrained. If , the upper side is present but too thin to support the usual back-and-forth traversal. If , the upper side disappears entirely. Hence the construction cannot rely on the upper part as a flexible passage region. In particular, the cycle cannot cross the upper side repeatedly; instead, the upper portion must be treated as a prescribed boundary segment and incorporated into the cycle in a controlled way. The detailed case analysis for this subcase remains to be completed, although we expect its construction to follow a similar approach to Sub Case I. As what is described in Sub Case I, each case of different parity combinations would make the way of constructing various, meanwhile, every case that has some parameters with the same parity, the Hamiltonian Path in that corresponding subgraph would be similar to each other.
5.3.3 Sub Case III:
When , the lower complementary side disappears. Therefore, the lower side cannot be used as a usual connecting corridor, and the cycle must be completed without relying on a bottom passage to reconnect different parts of the graph.
5.3.4 Sub Case IV:
When , the left complementary side disappears, so the left side can no longer be used as a connecting corridor. Similarly, the cycle must be organized using the remaining upper, right, and lower parts only, with the left boundary playing no transitional role.
Remaining Case Analysis. So far, we have focused on the detailed case analysis for Sub Case I (), while Sub Cases II, III, and IV remain to be completed. We expect these remaining cases to follow similar construction strategies. In particular, when or , the situation is similar to , since one of the connecting regions disappears, requiring the Hamiltonian cycle to be constructed through the remaining regions. The main difference lies in the location of the constrained boundary, which may require adjustments to the traversal direction and parity conditions. For Sub Case II (), when , the upper connecting region disappears, leading to a similar restriction. However, when , a single row remains above the hole, which may impose additional constraints on the Hamiltonian cycle construction. Therefore, although the general approach developed in Sub Case I may be extended to the remaining subcases, further case analysis is needed to establish the corresponding constructions and nonexistence conditions.
6 Rectangular-Decomposition Approach
6.1 Partition into Six Rectangular Subgraphs
We partition the rectangular grid graph with a three-stacked right-triangular hole into six rectangular subgraphs, denoted by , and , as illustrated in Figure 16. The partition follows the outer boundary and the three steps of the hole.
The upper-left subgraph extends from the left boundary of the grid to the column containing the rightmost vertex of the top layer of the hole. Its bottom row is one row above the top of the hole. The subgraph lies along the left side of the hole. It begins immediately below , stops at the row containing the bottom of the hole, and ends one column to the left of the hole's left edge. The subgraph lies below the hole, beginning one row below its bottom layer. It extends across the full width of the grid, from the left boundary to the right boundary. The subgraph occupies the right side: it extends from the top boundary down to the row containing the bottom of the hole, and its leftmost column is one column to the right of the hole's rightmost vertex.
The remaining two subgraphs lie above the steps of the hole. The subgraph is immediately to the right of and above the portion of the second layer that extends beyond the first layer. The subgraph lies between and , above the portion of the third layer that extends beyond the second layer. Thus, the rectangles along the top boundary occur in the order from left to right.
For a precise description, we use the coordinate convention from Section 3: is the top-left vertex, and the - and -coordinates increase to the right and downward, respectively. The top of the hole begins at row , and its three layers have heights . The left boundary of the hole is at column , while the rightmost columns of the layers are , , and , respectively. Thus, without introducing additional boundary variables, we obtain the following partition:
| Subgraph | Column range | Row range |
|---|---|---|
Equivalently, their widths and heights are
Here , in accordance with the vertical partition of the enclosing rectangle. We consider the nonempty rectangles with the necessary minimum dimensions when applying local Hamiltonian-cycle constructions. These ranges assign every remaining vertex to exactly one subgraph. Edges joining different subgraphs are retained as connections between the rectangular components.

Figure 16: Partition into six rectangular subgraphs. The gray region is removed.
6.2 Case Analysis by the Number of Odd-Sized Rectangles
We now organize the construction according to the number of odd-sized rectangles among . A rectangle is odd-sized if its number of vertices is odd, which only occurs if its width and height are both odd. Otherwise, it is even-sized.
Our objective is to construct a Hamiltonian cycle by repartitioning the graph into even-sized rectangles and merging their local cycles. The case analysis below gives explicit reductions for several parity configurations, while identifying others that still require a construction or compatibility argument. Accordingly, throughout this case analysis, we assume that admits a Hamiltonian cycle. In particular, has an even number of vertices. This is a necessary condition, rather than a sufficient condition for Hamiltonicity.
Since the six rectangles form a partition of the vertex set,
Reducing this identity modulo two shows that the number of odd-sized rectangles must be even. Therefore, the only possibilities are 0, 2, 4, and 6 odd-sized rectangles.
6.2.1 No Odd-Sized Rectangles
If there are no odd-sized rectangles, all six components are even-sized. Provided that each has width and height at least two, we construct a Hamiltonian cycle within each rectangle using the proposed rectangular construction. We then connect these local cycles through the parallel-edge merging operation. The local cycles must be chosen so that the required pairs of adjacent parallel edges are available at each merge. Once these compatible merges are performed, the resulting cycle covers every vertex of exactly once.
The remaining cases concern partitions containing odd-sized rectangles, which cannot individually admit Hamiltonian cycles. Our approach is to repartition appropriate regions into even-sized rectangles before constructing and merging their local cycles.
6.2.2 Case I: Exactly Two Odd-Sized Rectangles
The construction depends on the relative positions of the two odd-sized rectangles. The six components occur in the cyclic order
Here, adjacency refers to consecutive components in this order, which share an interface in the six-region partition. There are three possibilities: the two odd-sized rectangles are adjacent, separated by one rectangle along a shortest route in this order, or separated by two rectangles along either shortest route.
Case 1: Two adjacent odd-sized rectangular subgraphs. Suppose exactly two of the six rectangular subgraphs , and are odd-sized, and these two subgraphs are adjacent. There are six possible adjacent pairs: , and .
By rotating the corresponding pairs by clockwise, counterclockwise, and counterclockwise, respectively, each pair can be represented by the same configuration: two rectangular grid graphs sharing an aligned left boundary, where the upper rectangle is strictly wider than the lower rectangle, shown in Figure 17a. Therefore, it suffices to consider this representative case.

(a) Original partition.

(b) After repartitioning.
Figure 17: Repartitioning two adjacent odd-sized rectangular grid graphs into two even-sized rectangular grid graphs.
Let the upper and lower rectangular subgraphs be and , respectively, where , and are all odd, and . Since both rectangles have odd width and odd height, neither admits a Hamiltonian cycle individually.
We repartition by extending the right boundary of the bottom subgraphs( ) upward through the top one( ), as shown in Figure 17b. This produces two new rectangular subgraphs, denoted by and , with dimensions
Since and are odd, is even. Similarly, since and are odd, is even. Thus, has even width and has even height, implying that both are even-sized rectangular grid graphs.
Consequently, a Hamiltonian cycle can be constructed within each of and . By applying the previously established cycle-merging theorem, these two local Hamiltonian cycles can be connected to form a Hamiltonian cycle in . The resulting cycle can then be merged with the Hamiltonian cycles of the remaining even-sized rectangular subgraphs to obtain a Hamiltonian cycle in the original grid graph.
Case 2: Two odd-sized rectangular subgraphs separated by one subgraph. Suppose exactly two of the six rectangular subgraphs , and are odd-sized, and they are separated by exactly one even-sized rectangular subgraph. There are six possible pairs: , , , , , and .
Based on the relative positions of these subgraphs, we distinguish two representative configurations.
Configuration 1. The first configuration corresponds to , where lies between the two odd-sized subgraphs. The configurations , , and can be reduced to this configuration by rotating them by counterclockwise, and , respectively. Therefore, it suffices to consider the representative configuration shown in Figure 18a.
Let the upper, middle, and lower rectangular subgraphs be , , and , respectively. The subgraphs and share an aligned left boundary, while and share an aligned bottom boundary. Furthermore, the right edge of is adjacent to the left edge of along their overlapping portion. We have

(a) Original partition.

(b) After boundary reassignment.
Figure 18: Repartitioning three staggered rectangular subgraphs with two nonadjacent odd-sized subgraphs.
Since and are odd-sized, are all odd. The repartitioning depends on the parity of and .
(i) is odd and is even.
We first apply the repartitioning operation introduced in Case 1 to and , extending the right boundary of upward through . We then extend the bottom boundary of rightward through . As shown in Figure 18b, this produces three new rectangular subgraphs, denoted by , , and , with dimensions
All three new regions after boundary reassignment are even size: and are odd, so is even; and are odd, is even, so is even; and are odd, so is even.
Followed by Algorithm 1, a Hamiltonian cycle can be constructed within each of , , and . By Theorem 4.8, these three local Hamiltonian cycles can be connected one by one to form a Hamiltonian cycle. The connected Hamiltonian cycle can then merge with the Hamiltonian cycles of the remaining three regions.
(ii) is even and is odd.
In this case, we repartition the three rectangular subgraphs into five even-sized rectangular subgraphs. We first separate vertically into two odd-width rectangles, then apply boundary reassignment to and . Afterward, we separate horizontally and apply another boundary reassignment to its upper part and , as shown in Figure 19.
Specifically, we first divide vertically into two rectangular subgraphs, denoted by and , where
and both and are odd. Since is odd, both and are odd-sized rectangular subgraphs.
We then extend the upper boundary of leftward through . This produces two new rectangular subgraphs, denoted by and . Next, we separate horizontally into an upper part and a bottom part , such that

(a) Original partition.

(b) Vertical separation of .

(c) Reassignment of and .

(d) Horizontal separation of

(e) Final partition into five even-sized rectangles.
Figure 19: Repartitioning three staggered rectangular subgraphs when is even and is odd. The middle rectangle is first separated vertically into two odd-width rectangles. After boundary reassignment with , the left rectangle is separated horizontally and its upper portion is combined with part of . The resulting five rectangular subgraphs are all even-sized.
where is odd and is even.
Finally, we apply the boundary reassignment introduced in Case 1 to and , extending the right boundary of upward through . This produces and .
As shown in Figure 19e, the resulting five rectangular subgraphs are , , , , and , with dimensions
All five resulting rectangular subgraphs are even-sized. Since and are odd, is even. Similarly, since and are odd, is even. Since and are odd, is even. By construction, is even. Finally, since and are odd, is even.
Therefore, all five resulting rectangular subgraphs are even-sized.
Provided that each resulting rectangle has width and height at least two, a Hamiltonian cycle can be constructed within each of , , , , and by Algorithm 1. By applying Theorem 4.8 whenever the required compatible boundary edges are available, these five local Hamiltonian cycles can be connected successively to form a Hamiltonian cycle in the union of the three original subgraphs. The resulting cycle can then be merged with the Hamiltonian cycles of the remaining three regions to obtain a Hamiltonian cycle in the original grid graph.
(iii) and are both even.
We claim that this configuration does not admit a Hamiltonian cycle because the numbers of black and white vertices are unequal. A proof based on the bipartite coloring of the grid graph will be provided.

(a) Original partition.

(b) After repartitioning.
Figure 20: Repartitioning three horizontally adjacent rectangular subgraphs into three even-sized rectangular subgraphs.
Configuration 2
The second configuration corresponds to , where lies between the two odd-sized subgraphs. The configuration can be reduced to this configuration by reflection. Therefore, it suffices to consider the representative configuration shown in Figure 20a.
Let the three rectangular subgraphs, from left to right, be , , and . They share an aligned top boundary, and their heights satisfy
The right boundary of is adjacent to the upper portion of the left boundary of , while the right boundary of is adjacent to the upper portion of the left boundary of .
Since and are odd-sized, are all odd. We distinguish the following cases according to the parity of .
(i) is even.
In this case, is either even by odd or even by even. We repartition the three subgraphs by extending the bottom boundary of rightward through and , as shown in Figure 20b.
This produces three new rectangular subgraphs, denoted by , , and , with dimensions
Since and are odd and is even, is even. Thus, is even-sized. Since is even, is also even-sized, regardless of the parity of .
Finally, since and are odd, is even. Thus, is even-sized.
Consequently, all three resulting rectangular subgraphs are even-sized.
(ii) is odd and is even.
This case can be handled using a repartitioning strategy similar to that introduced in Configuration 1(ii). However, the detailed construction and correctness analysis have not yet been completed and are left for future work.
For the completed cases, a Hamiltonian cycle can be constructed within each resulting even-sized rectangular subgraph. By applying the previously established cycle-merging theorem, these local cycles can be connected to form a Hamiltonian cycle in the union of the three subgraphs. The resulting cycle can then be merged with the Hamiltonian cycles of the remaining even-sized rectangular subgraphs to obtain a Hamiltonian cycle in the original grid graph.
6.2.3 Case II: Exactly Four Odd-Sized Rectangles
Suppose exactly four of the six rectangular subgraphs are odd-sized. Recall that these subgraphs occur in the cyclic adjacency order
We first show that at least two of the odd-sized rectangles must be adjacent. Consider the three disjoint pairs of consecutive rectangles
If no two odd-sized rectangles were adjacent, each of these pairs could contain at most one odd-sized rectangle. Hence there would be at most three odd-sized rectangles, contradicting the assumption that there are four. Therefore, at least one adjacent odd-sized pair must exist.
Choose such a pair and apply the adjacent-odd repartitioning introduced in Case I, whenever its geometric and minimum-dimension conditions are satisfied. The chosen pair is then replaced by even-sized rectangular subgraphs while preserving the underlying vertex set. The two remaining odd-sized rectangles can be examined using the constructions from Case I: if they are adjacent, use the adjacent-pair repartitioning; if they are separated, use the appropriate three-rectangle repartitioning according to their relative positions and the parity of the intervening rectangle.
This yields a reduction strategy from four odd-sized rectangles to the two-odd configurations already considered. However, after the first boundary adjustment, the second pair must be analyzed in the updated partition rather than in the original six-region diagram. In particular, it remains necessary to verify that the first cut does not invalidate the second repartitioning, that all resulting rectangles have dimensions at least two, and that their local Hamiltonian cycles admit a compatible sequence of edge exchanges. Thus, the adjacency argument guarantees a candidate first pair, but does not by itself establish a Hamiltonian cycle for every four-odd configuration.
6.2.4 Case III: Six Odd-Sized Rectangles
Suppose all six rectangular subgraphs are odd-sized. We consider the three pairs of adjacent rectangular subgraphs
For each pair, we apply the boundary reassignment introduced in Case I.
Specifically, for the pair , we extend the right boundary of upward through . For the pair , we extend the left boundary of downward through . Finally, for , we extend the bottom boundary of rightward through .
Figure 21 illustrates the original partition and the partition obtained after these three boundary adjustments. The operations preserve the vertex set of the original graph while changing the dimensions of the rectangular components.
When both rectangles in each pair are odd-sized and the required geometric conditions hold, the adjacent-pair repartitioning produces even-sized rectangles. Hamiltonian cycles can then be constructed locally, provided that each resulting rectangle has both dimensions at least two, and merged through compatible boundary edges.

(a) Original six-region partition.

(b) After the three pairwise boundary reassignments.
Figure 21: Repartitioning the six rectangular subgraphs through three pairwise boundary adjustments: , , and . The original partition is shown in (a), while (b) illustrates the resulting rectangular partition. The triangular hole and the set of retained vertices remain unchanged.
7 Discussion
8 Discussion
The geometry-driven construction distinguishes between small-hole and large-hole cases. The small-hole procedure constructs a path in the reversed triangular region, closes it through the bounding rectangle, and merges the inner and outer cycles through parallel edges. The large-hole analysis considers the parity cases for and describes the constrained upper, lower, and left sides. The remaining detailed large-hole cases and the nonadjacent repartitioning cases require further analysis to establish completeness.
Furthermore, the rectangular-decomposition approach relies on repartitioning the original rectangular subgraphs into smaller rectangular regions. Since each resulting region must have width and height at least two to admit a Hamiltonian cycle, additional analysis is needed to determine the minimum allowable values of the relevant parameters under which the proposed repartitioning operations remain valid. In particular, when the original regions are too narrow or too short, some resulting subgraphs may not satisfy the minimum dimension requirements. These boundary cases require separate analysis or alternative constructions to establish the completeness of the approach.
References
[1] Karla L Hoffman, Manfred Padberg, Giovanni Rinaldi, et al. Traveling salesman problem. Encyclopedia of operations research and management science, 1:1573–1578, 2013.
[2] Ruo-Wei Hung. Hamiltonian cycles in linear-convex supergrid graphs. Discrete Applied Mathematics, 211:99–112, 2016.
[3] Ruo-Wei Hung, Chih-Chia Yao, and Shang-Ju Chan. The hamiltonian properties of supergrid graphs. Theoretical Computer Science, 602:132–148, 2015.
[4] Alon Itai, Christos Papadimitriou, and Jayme Szwarcfiter. Hamilton paths in grid graphs. SIAM J. Comput., 11:676–686, 11 1982.
[5] Fatemeh Keshavarz-Kohjerdi and Alireza Bagheri. Hamiltonian paths in c-shaped grid graphs, 2016.
[6] Fatemeh Keshavarz-Kohjerdi and Alireza Bagheri. Hamiltonian paths in l-shaped grid graphs. Theoretical Computer Science, 621:37–56, 2016.
[7] Fatemeh Keshavarz-Kohjerdi and Alireza Bagheri. A linear-time algorithm for finding hamiltonian (s, t)-paths in odd-sized rectangular grid graphs with a rectangular hole. J. Supercomput., 73(9):3821–3860, 2017.
[8] Fatemeh Keshavarz-Kohjerdi and Alireza Bagheri. A linear-time algorithm for finding hamiltonian (s,t)-paths in even-sized rectangular grid graphs with a rectangular hole. Theoretical Computer Science, 690:26–58, 2017.
[9] Fatemeh Keshavarz-Kohjerdi and Alireza Bagheri. Linear-time algorithms for finding hamiltonian and longest (s,t)-paths in c-shaped grid graphs. Discrete Optimization, 35:100554, 2020.
[10] R. Lewis, P. Corcoran, and A. Gagarin. Methods for determining cycles of a specific length in undirected graphs with edge weights. J. Comb. Optim., 46(5), November 2023.
[11] Rajesh Matai, Surya Prakash Singh, and Murari Lal Mittal. Traveling salesman problem: an overview of applications, formulations, and solution approaches. Traveling salesman problem, theory and applications, 1(1):1–25, 2010.
[12] Movahedeh Rouhani-Marchoobeh and Fatemeh Keshavarz-kohjerdi. Hamiltonicity of rectangular grid graphs (meshes) with an l-shaped hole. Revista de la Unión Matemática Argentina, pages 611–625, 10 2025.
[13] C. Umans and W. Lenhart. Hamiltonian cycles in solid grid graphs. In Proceedings 38th Annual Symposium on Foundations of Computer Science, pages 496–505, 1997.