The Hamiltonicity and Hamiltonian Connectivity of L-shaped Supergrid Graphs Ruo-Wei Hung 1,∗ , Jun-Lin Li 1 , and Chih-Han Lin 1 Abstract—Supergrid graphs include grid graphs and trian- gular grid graphs as their subgraphs. The Hamiltonian path problem for general supergrid graphs is a well-known NP- complete problem. A graph is called Hamiltonian connected if there exists a Hamiltonian path between any two distinct vertices. In the past, we verified the Hamiltonian connectivity of some special supergrid graphs, including rectangular, trian- gular, parallelogram, trapezoid, and alphabet supergrid graphs, except few trivial conditions. In this paper, we will prove that every L-shaped supergrid graph always contains a Hamiltonian cycle except one trivial condition. We also present necessary and sufficient conditions for the existence of a Hamiltonian path between two given vertices in L-shaped supergrid graphs. The Hamiltonian connectivity of L-shaped supergrid graphs can be applied to compute the optimal stitching trace of computer embroidering machines while a varied-sized letter L is sewed into an object. Index Terms—Hamiltonicity, Hamiltonian connectivity, longest path, supergrid graphs, computer embroidering machines. I. I NTRODUCTION A Hamiltonian path (resp., cycle) in a graph is a simple path (resp., cycle) in which each vertex of the graph appears exactly once. The Hamiltonian path (resp., cycle) problem involves deciding whether or not a graph contains a Hamiltonian path (resp., cycle). A graph is called Hamilto- nian if it contains a Hamiltonian cycle. A graph G is said to be Hamiltonian connected if for every pair of distinct vertices u and v of G, there is a Hamiltonian path from u to v in G. If (u, v) is an edge of a Hamiltonian connected graph, then there exists a Hamiltonian cycle containing edge (u, v). Thus, a Hamiltonian connected graph contains many Hamiltonian cycles, and, hence, the sufficient conditions of Hamiltonian connectivity are stronger than those of Hamiltonicity. The longest path problem is to find a simple path with the maximum number of vertices in a graph. The Hamiltonian path problem is clearly a special case of the longest path problem. The Hamiltonian path and cycle problems have numerous applications in different areas, including establishing trans- port routes, production launching, the on-line optimization of flexible manufacturing systems [1], computing the perceptual boundaries of dot patterns [37], pattern recognition [2], [39], [42], DNA physical mapping [14], and fault-tolerant routing for 3D network-on-chip architectures [9]. It is well Manuscript received October 28, 2017; revised November 13, 2017. This work was supported in part by the Ministry of Science and Technology of Taiwan (R.O.C.) under grant no. MOST 105-2221-E-324- 010-MY3. 1 Ruo-Wei Hung, Jun-Lin Li, and Chin-Han Lin are with the Department of Computer Science and Information Engineering, Chaoyang University of Technology, Wufeng, Taichung 41349, Taiwan. * Corresponding author e-mail: rwhung@cyut.edu.tw. known that the Hamiltonian path and cycle problems are NP- complete for general graphs [11], [26]. The same holds true for bipartite graphs [32], split graphs [12], circle graphs [8], undirected path graphs [3], grid graphs [25], triangular grid graphs [13], and supergrid graphs [20]. In the literature, there are many studies for the Hamiltonian connectivity of interconnection networks, including WK- recursive network [10], recursive dual-net [34], hypercom- plete network [5], alternating group graph [27], arrangement graph [36]. The popular hypercubes are Hamiltonian but are not Hamiltonian connected. However, many variants of hy- percubes, including augmented hypercubes [19], generalized base-b hypercube [18], hypercube-like networks [38], twisted cubes [17], crossed cubes [16], M¨ obius cubes [7], folded hypercubes [15], and enhanced hypercubes [35], have been known to be Hamiltonian connected. A supergrid graph is a graph in which vertices lie on integer coordinates and two vertices are adjacent if and only if the difference of their x or y coordinates is not greater than 1. Let v =(v x ,v y ) be a vertex in a supergrid graph, where v x and v y represent the x and y coordinates of v, respectively. Then, the possible adjacent vertices of v include (v x ,v y − 1), (v x − 1,v y ), (v x +1,v y ), (v x ,v y + 1), (v x − 1,v y − 1), (v x +1,v y + 1), (v x +1,v y − 1), and (v x − 1,v y + 1). Let R(m, n) be the supergrid graph whose vertex set V (R(m, n)) = {v =(v x ,v y )|1 v x m and 1 v y n}.A rectangular supergrid graph is a supergrid graph which is isomorphic to R(m, n). Let L(m, n; k,l) be a supergrid graph obtained from a rectangular supergrid graph R(m, n) by removing its subgraph R(k,l) from the upper right corner. A L-shaped supergrid graph is isomorphic to L(m, n; k,l). In this paper, we only consider L(m, n; k,l). The possible application of the Hamiltonian connectiv- ity of L-shaped supergrid graphs is presented as follows. Consider a computerized embroidery machine to embroider the object, e.g., clothes, with a L letter. First, we produce a set of lattices to represent the letter. Then, a path is computed to visit the lattices of the set such that each lattice is visited exactly once. Finally, the software transmits the stitching trace of the computed path to the computerized embroidering machine, and the machine then performs the stitching work along the trace on the object. Since each stitch position of an embroidering machine can be moved to its eight neighboring positions (left, right, up, down, up-left, up-right, down-left, and down-right), one set of neighboring lattices forms a L-shaped supergrid graph. Note that each lattice will be represented by a vertex of a supergrid graph. The desired stitching trace of the set of adjacent lattices is the Hamiltonian path of the corresponding L-shaped supergrid graph. The width and height of L-shaped supergrid graph L(m, n; k,l) can be adjusted according to the parameters m, Proceedings of the International MultiConference of Engineers and Computer Scientists 2018 Vol I IMECS 2018, March 14-16, 2018, Hong Kong ISBN: 978-988-14047-8-7 ISSN: 2078-0958 (Print); ISSN: 2078-0966 (Online) IMECS 2018