• Tidak ada hasil yang ditemukan

Hamiltonian Paths in Some Classes of Grid Graphs

N/A
N/A
Protected

Academic year: 2024

Membagikan "Hamiltonian Paths in Some Classes of Grid Graphs"

Copied!
18
0
0

Teks penuh

(1)

Volume 2012, Article ID 475087,17pages doi:10.1155/2012/475087

Research Article

Hamiltonian Paths in Some Classes of Grid Graphs

Fatemeh Keshavarz-Kohjerdi

1

and Alireza Bagheri

2

1Department of Computer Engineering, Islamic Azad University, North Tehran Branch, Tehran, Iran

2Department of Computer Engineering and IT, Amirkabir University of Technology, Hafez Avenue, Tehran, Iran

Correspondence should be addressed to Fatemeh Keshavarz-Kohjerdi, [email protected]

Received 8 September 2011; Revised 13 December 2011; Accepted 28 December 2011 Academic Editor: Jin L. Kuang

Copyrightq2012 F. Keshavarz-Kohjerdi and A. Bagheri. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

The Hamiltonian path problem for general grid graphs is known to be NP-complete. In this paper, we give necessary and sufficient conditions for the existence of Hamiltonian paths inL-alphabet, C-alphabet,F-alphabet, andE-alphabet grid graphs. We also present linear-time algorithms for finding Hamiltonian paths in these graphs.

1. Introduction

Hamiltonian path in a graph is a simple path that visits every vertex exactly once. The prob- lem of deciding whether a given graph has a Hamiltonian path is a well-known NP-complete problem and has many applications1,2. However, for some special classes of graphs poly- nomial-time algorithms have been found. For more related results on Hamiltonian paths in general graphs see3–8.

Rectangular grid graphs first appeared in9, where Luccio and Mugnia tried to solve the Hamiltonian path problem. Itai et al.10gave necessary and sufficient conditions for the existence of Hamiltonian paths in rectangular grid graphs and proved that the problem for general grid graphs is NP-complete. Also, the authors in11presented sufficient conditions for a grid graph to be Hamiltonian and proved that all finite grid graphs of positive width have Hamiltonian line graphs. Later, Chen et al.12improved the algorithm of10 and presented a parallel algorithm for the problem in mesh architecture. Also there is a polynomial-time algorithm for finding Hamiltonian cycle in solid grid graphs13. Recently, Salman14introduced alphabet grid graphs and determined classes of alphabet grid graphs which contain Hamiltonian cycles. More recently, Islam et al.15showed that the Hamiltoni- an cycle problem in hexagonal grid graphs is NP-complete. Also, Gordon et al.16proved that all connected, locally connected triangular grid graphs are Hamiltonian, and gave a

(2)

sufficient condition for a connected graph to be fully cycle extendable and also showed that the Hamiltonian cycle problem for triangular grid graphs is NP-complete. Nandi et al.

17 gave methods to find the domination numbers of cylindrical grid graphs. Moreover, Keshavarz-Kohjerdi et al.18, 19 gave sequential and parallel algorithms for the longest path problem in rectangular grid graphs.

In this paper, we obtain necessary and sufficient conditions for the existence of a Ham- iltonian path inL-alphabet, C-alphabet,F-alphabet, andE-alphabet grid graphs. Also, we present linear-time algorithms for finding such a Hamiltonian path in these graphs. Solving the Hamiltonian path problem for alphabet grid graphs may arise results that can help in solving the problem for general solid grid graphs. The alphabet grid graphs that are consid- ered in this paper have similar properties that motivate us to investigate them together. Other classes of alphabet grid graphs have enough differences that will be studied in a separate work.

2. Preliminaries

Some previously established results about the Hamiltonian path problem which plays an im- portant role in this paper are summarized in this section.

Thetwo-dimensional integer gridGis an infinite graph with vertex set of all points of the Euclidean plane with integer coordinates. In this graph, there is an edge between any two vertices of unit distance. For a vertexvof this graph, letvx andvy denotexand ycoordi- nates of its corresponding point. A grid graphG is a finite vertex-induced subgraph of the two-dimensional integer grid. In a grid graphG, each vertex has degree of at most four. A rectangular grid graphRm, n orRfor shortis a grid graph whose vertex set isVR {υ| 1≤υxm, 1≤υyn}.Rm, nis called ann-rectangle. A solid grid graph is a grid graph without holes.

By10, a vertexvis coloredwhiteifυx υyis even, and is coloredblackotherwise. The size ofRm, nis defined to bemn.Rm, nis calledodd sizedifmnis odd, and is calledeven sizedotherwise. Two different verticesυandυinRm, nare calledcolor compatibleif either bothυandυare white andRm, nis odd sized, orυandυhave different colors andRm, n is even sized.

An alphabet grid graph is a finite vertex-induced subgraph of the rectangular grid graph of a certain type, as follows. Form, n ≥3, anL-alphabet grid graphLm, n orLfor short,C-alphabet grid graphCm, n orCfor short,F-alphabet grid graphFm, n orFfor short, andE-alphabet grid graphEm, n orEfor shortare subgraphs ofR3m−2,5n−4.

These alphabet grid graphs are shown inFigure 1, form 4 andn 3. An alphabet grid graph is calledodd sizedif its corresponding rectangular graph is odd sized, and is calledeven sizedotherwise.

In the following byAm, nwe mean a grid graphAm, n. LetPAm, n, s, tdenote the problem of finding a Hamiltonian path between verticessandtin grid graphAm, n, and letAm, n, s, tdenote the grid graphAm, nwith two specified distinct verticessand tof it. WhereAis a rectangular grid graph,L-alphabet,C-alphabet,F-alphabet, orE-alphabet grid graph. Am, n, s, tis Hamiltonianif there is a Hamiltonian path between s andt in Am, n. In this paper, without loss of generality we assumesxtxandmn. In the figures, we assume that1,1is the coordinates of the vertex in the lower left corner.

An even-sized rectangular grid graph contains the same number of black and white vertices. Hence, the two end vertices of any Hamiltonian path in the graph must have

(3)

3m2

5n4

a

4n4

2m2

m

n

b

m

n n

3n4

2m2

c

n2

m

2m4

n

n

2n2

d

m

n2

2m4

n

n

n

2m2 e

Figure 1:aA rectangular grid graphR10,11,banL-alphabet grid graphL4,3,canC-alphabet grid graphC4,3,danF-alphabet grid graphF4,3,eanE-alphabet grid graphE4,3.

s t

a

s t

b

s t c

s t

d

Figure 2:Rectangular grid graphs in which there is no Hamiltonian path betweensandt.

different colors. Similarly, in an odd sized rectangular grid graph the number of white verti- ces is one more than the number of black vertices. Therefore, the two end vertices of any Ham- iltonian path in such a graph must be white. Hence, the color compatibility ofsandtis a nec- essary condition forRm, n, s, tto be Hamiltonian. Furthermore, Itai et al.10showed that if one of the following conditions hold, thenRm, n, s, tis not Hamiltonian:

F1Rm, nis a 1-rectangle and eithersortis not a corner vertexFigure 2a.

F2Rm, nis a 2-rectangle ands, tis a nonboundary edge, thats, tis an edge and it is not on the outer faceFigure 2b.

(4)

a b

Figure 3:A Hamiltonian cycle for the rectangular grid graphR8,5andL-alphabet grid graphL4,3.

F3Rm, nis isomorphic to a 3-rectangleRm, nsuch thatsandtare mapped tos andtand all of the following three conditions hold:

1mis even,

2sis black,tis white,

3sy 2 andsx< txFigure 2corsy/2 andsx< tx−1Figure 2d.

A Hamiltonian path problemPRm, n, s, t is calledacceptableif sand tare color compatible andR, s, tdoes not satisfy any of conditionsF1,F2, andF3.

The following theorem has been proved in10.

Theorem 2.1. LetRm, nbe a rectangular grid graph and sandt be two distinct vertices. Then Rm, n, s, tis Hamiltonian if and only ifPRm, n, s, tis acceptable.

Lemma 2.2see12. Rm, nhas a Hamiltonian cycle if and only if it is even-sized andm, n >1.

Lemma 2.3see14. AnyL-alphabet grid graphLm, n m, n≥ 3has a Hamiltonian cycle if and only ifmnis even.

Figure 3shows a Hamiltonian cycle for an even-sized rectangular grid graph andL- alphabet graphLm, n, found by Lemmas2.2and2.3, respectively. Each Hamiltonian cycle found by these lemmas contains all boundary edges on three sides of the rectangular graph and four sides of theL-alphabet grid graph. This shows that for an even-sized rectangular graphRandL-alphabet graphLm, n, we can always find a Hamiltonian cycle, such that it contains all boundary edges, except of exactly one side ofRand two side ofLwhich contains an even number of vertices.

3. Necessary and Sufficient Conditions

In this section, we give necessary and sufficient conditions for the existence of a Hamiltonian path inL-alphabet,C-alphabet,F-alphabet, andE-alphabet grid graphs.

(5)

s

t L(m, n) RL

e1 e2

a

s

t

b Figure 4:A Hamiltonian path inR10,11.

Definition 3.1. Aseparationof

ian L-alphabet grid graphLm, nis a partition ofL into two disjoint rectangular grid graphsR1andR2, that is,VL VR1VR2, andVR1VR2 ∅, iianC-alphabet graphCm, nis a partition ofCinto aL-alphabet graphLm, nand

a rectangular grid graphR2m−2, n, that is,VC VLVR2m−2, n, and VLVR2m−2, n ∅,

iiianF-alphabet grid graphFm, nis a partition ofF into aL-alphabet grid graph Lm, nand a rectangular grid graphR2m−4, n or four rectangular grid graphs R1toR4, that is,VF VLVR2m−4, nandVLVR2m−4, n ∅or VF VR1VR2VR3VR4andVR1VR2VR3VR4 ∅, ivanE-alphabet grid graphEm, nis a partition ofEinto anF-alphabet grid graph

Fm, n and a rectangular grid graph R2m −2, n or a C-alphabet grid graph Cm, nand a rectangular grid graphR2m−4, n, that is,VE VFVR2m− 2, n, andVFVR2m−2, n ∅ or VE VCVR2m−4, n, and VCVR2m−4, n ∅.

In the following, two nonincident edgese1ande2are parallel, if each end vertex ofe1

is adjacent to some end vertex ofe2.

Lemma 3.2. LetAm, nbe anL-alphabet,C-alphabet,F-alphabet, orE-alphabet grid graph andR be the smallest rectangular grid graph that includesA. IfAm, n, s, tis Hamiltonian, thenR, s, t is also Hamiltonian.

Proof. We break the proof into two cases.

Case 1Am, nis anL-alphabet orC-alphabet grid graph. LetPbe a Hamiltonian path inL orCthat is found byAlgorithm 1or2. SinceRLorRCis an even-sized rectangular grid graph of2m−2×4n−4 or2m−2×3n−4, then byLemma 2.2it has a Hamiltonian cyclei.e., we can find a Hamiltonian cycle ofRLorRC, such that it contains all edges ofRLorRCthat are parallel to some edge ofP. Using two parallel edges ofPand the Hamiltonian cycle ofRL orRCsuch as two darkened edges of Figure 4a, we can combine them as illustrated inFigure 4band obtain a Hamiltonian path forR.

(6)

e1

e2

v1 v2

a

s t

b

s t

c Figure 5:A Hamiltonian path inR7,11.

Case 2. Am, nis anF-alphabet orE-alphabet grid graph. LetP be a Hamiltonian path inF orEthat is found byAlgorithm 3or4. We consider the following cases.

Subcase 2.1m, n >3. SinceRForREcan be partitioned into three even-sized rectangu- lar grid graphs ofR2m−4, n−2,R2,2n−2, andR2m−2,2n−2 orR2,3n−4, R2m−4, n

2, andR2m−4, n−2, then they have Hamiltonian cycles byLemma 2.2. Then combine Hamiltonian cycles onR2m−4, n−2,R2,2n−2andR2m−2,2n−2 orR2,3n−4, R2m

4, n−2, andR2m−4, n−2to be a large Hamiltonian cycle and then using two parallel edg- es ofPand the Hamiltonian cycle ofRForRE, we can obtain a Hamiltonian path forR.

Subcase 2.2n3. LetRFbe three rectangular grid graphs ofR2m−4, n−2,R2,2n−2, andR2m−2,2n−2. We consider the following two subcases.

Subcase2.2.1 m3. Let two verticesv1, v2be inR2m−4, n−2. UsingAlgorithm 3there exist two edgese1, e2such thate1P ore2Pis on the boundary ofFm, nfacingR2m− 4, n−2, seeFigure 5a. Hence by combining a Hamiltonian pathPand Hamiltonian cycles in R2,2n−2andR2m−2,2n−2andv1, v2, a Hamiltonian path betweensandtis obtained, see Figures5band5c.

Subcase2.2.2 m >3. Form 4, let four verticesv1, v2, v3, v4 be inR2m−4, n−2. Using Algorithm 3there exist four edgese1, e2, e3, e4 such thate1, e2P,e1, e4P,e3, e4P or e2, e3Pare on the boundary ofFm, nfacingR2m−4, n−2seeFigure 6a. Therefore, by mergingv1, v2andv3, v4to these edges and Hamiltonian cycles inRFwe obtain a Hamiltonian path forR, seeFigure 6b. For other values ofm, the proof is similar to that of m4.

Similar toF-alphabet grid graphs, Hamiltonian paths can be found inE-alphabet grid graphs forn3.

CombiningLemma 3.2andTheorem 2.1the following corollary is trivial.

Corollary 3.3. LetAm, nbe anL-alphabet,C-alphabet,F-alphabet, orE-alphabet grid graph andR be the smallest rectangular grid graph that includesA. IfAm, n, s, tis Hamiltonian, thensandt must be color compatible inR.

(7)

e1 e2

v1 v2

e3 e4

v3 v4

a

s

t

b Figure 6:A Hamiltonian path inR7,11.

Therefore, the color compatibility of s and t in R is a necessary condition for Lm, n, s, t,Cm, n, s, t,Fm, n, s, t, andEm, n, s, tto be Hamiltonian.

Definition 3.4. The length of a path in a grid graph means the number of vertices of the path. In any grid graph, the length of any path between two same-colored vertices is odd and the length of any path between two different-colored vertices is even.

Lemma 3.5. LetR2m−2, nandRm,5n−4be a separation ofLm, nsuch that three verticesv, w, anduare inR2m−2, nwhich are connected toRm,5n−4. Assume thatsandtare two given vertices ofLandswandtt, ifsR2m−2, nletss. Iftx> m 1andR2m−2, n, s, t satisfies condition (F3), thenLm, ndoes not have any Hamiltonian path betweensandt.

Proof. Without loss of generality, let s and t be color compatible. Since m, n ≥ 3 and by Theorem 2.1a rectangular grid graph does not have a Hamiltonian path only in condition F3, so it suffices to prove the lemma for the casen 3. Assume thatR2m−2, nsatisfies condition F3. We show that there is no Hamiltonian path in Lm, n between s and t.

Assume to the contrary thatLm, nhas a Hamiltonian pathP. Sincen3 there are exactly three verticesv, wanduinR2m−2, nwhich are connected toRm,5n−4, as shown in Figure 7a. Then the following cases are possible.

Case 1. tR2m−2, nands /R2m−2, n. The following subcases are possible for the Hamil- tonian pathP.

Subcase 1.1. The Hamiltonian pathPofLm, nthat starts fromsmay enter toR2m−2, nfor the first time through one of the verticesv, w, oru, pass through all the vertices ofR2m−2, n and end att, seeFigure 7b. This case is not possible because we assumed thatR2m−2, n satisfiesF3, in this casettandsw.

Subcase 1.2. The Hamiltonian pathPofLm, nmay enter toR2m−2, n, pass through some vertices of it, then leave it and enter it again and pass through all the remaining vertices of it and finally end att. In this case, two subpaths ofPwhich are inR2m−2, nare calledP1and P2,P1fromvtouvtoworutowandP2fromwtotutotorvtot. This case is not also

(8)

R(m,5n4)

v w u

R(2m2, n)

a

v w u

s t s

t

b Figure 7:A separation ofL4,3.

possible because the size ofP1is oddevenand the size ofP2is evenodd, then|P1 P2|is odd whileR2m−2, nis even, which is a contradiction.

Case 2s, tR2m−2, n. The following cases may be considered.

Subcase 2.1. The Hamiltonian pathP ofLm, nwhich starts fromsmay pass through some vertices ofR2m−2, n, leaveR2m−2, natvoru, then passes through all the vertices of Rm,5n−4and reenter toR2m−2, natwgo touorvand pass through all the remaining vertices ofR2m−2, nand end att. In this case by connectingvorutowwe obtain a Hamil- tonian path fromstotinR2m−2, n, which contradicts the assumption thatR2m−2, n satisfiesF3.

Subcase 2.2. The Hamiltonian pathPofLm, nwhich starts fromsmay leaveR2m−2, nat voru, then pass through all the vertices ofRm,5n−4and reenter toR2m−2, natuor vgo tow and pass through all the remaining vertices ofR2m−2, nand end att. In this case, two parts ofP reside inR2m−2, n. The partP1starts fromsends atvoru, and the partP2starts fromuorvends att. The size ofP1is even and the size ofP2is odd while the size ofR2m−2, nis even, which is a contradiction.

Subcase 2.3. Another case that may arise is that the Hamiltonian pathPofLm, nstarts from sleavesR2m−2, natwand reentersR2m−2, natvoruand then goes tot. But in this case vertexuorvcannot be inP, which is a contradiction. Thus, the proof ofLemma 3.5is completed.

Lemma 3.6. LetLm, nandR2m−2, nbe a separation ofCm, nsuch that three verticesv1,w1, andu1are inR2m−2, nwhich are connected toLm, nandxLm, nis a adjacent vertex tow1. Assume thatsandtare two given vertices ofC. IftLm, nandsR2m−2, n, letsxand sw1,ts, respectively. IfLm, n, s, tdoes not have a Hamiltonian path orR2m−2, n, s, t satisfies condition (F3), thenCm, ndoes not have a Hamiltonian path betweensandt.

Proof. The proof is similar to the proof ofLemma 3.5, for more details seeFigure 8.

Lemma 3.7. LetLm, nandR2m−4, nbe a separation ofFm, nsuch that three verticesv1,w1, andu1are inR2m−4, nwhich are connected toLm, nandxLm, nis an adjacent vertex to

(9)

L(m, n)

v1

w1

u1

s t

R(2m2, n)

a

L(m, n)

x s

t

w1

R(2m2, n) s

t s

b

x L(m, n)

s

t w1

s t R(2m2, n) s

c

Figure 8:C-alphabet grid graphs in which there is no Hamiltonian path betweensandt.

L(m, n)

s t v1

w1

u1

x

s

t t

a

L(m, n)

w1

x s

s

t

s

t

b

s

t v w u

L(m, n)

s t

c

Figure 9:F-alphabet grid graphs in which there is no Hamiltonian path betweensandt.

w1. Assume thatsandtare two given vertices ofF. Ifs, tR2m−4, nletssandtt; ifs(ort)

R2m−4, nletsw1andts(orsw1andtt); ift(ors)Lm, nletsxts, sx ort x. IfLm, n, s, tdoes not have a Hamiltonian path orR2m−4, n, s, tsatisfies the condition (F3), thenFm, ndoes not have a Hamiltonian path betweensandt.

Proof. By a similar way as used in theLemma 3.5we can prove this lemma; for more details seeFigure 9.

Lemma 3.8. LetFm, nandR2m−2, norCm, nandR2m−4, nbe a separation ofEm, n and s and t be two given vertices inEm, n. IfFm, n, s, t or Cm, n, s, t does not have a Hamiltonian path, thenEm, ndoes not have a Hamiltonian path betweensandt.

Proof. The proof is similar to the proof ofLemma 3.5, for more details seeFigure 10.

From Corollary 3.3 and Lemmas 3.5, 3.6,3.7, and 3.8, a Hamiltonian path problem PLm, n, s, t is called acceptable if s and t are color-compatible and R2m −2, n, s, t

(10)

F(m, n)

R(2m2n, n) s

t

a

C(m, n)

s t

b

Figure 10:E-alphabet grid graphs in which there is no Hamiltonian path betweensandt.

does not satisfy the condition F3; PCm, n, s, t is called acceptable if PLm, n, s, t is acceptable andR2m−2, n, s, tdoes not satisfy the conditionF3;PFm, n, s, tis called acceptableifPLm, n, s, tis acceptable andR2m−4, n, s, tdoes not satisfy the condition F3;PEm, n, s, tis calledacceptableifPFm, n, s, tandCm, n, s, tare acceptable.

Theorem 3.9. Let Am, nbe an L-alphabet,C-alphabet,F-alphabet or E-alphabet grid graph. If Am, n, s, tis Hamiltonian, thenPAm, n, s, tis acceptable.

Now, we show that all acceptable Hamiltonian path problems have solutions by introducing algorithms to find Hamiltonian pathssufficient conditions. Our algorithms are based on a divide-and-conquer approach. In the dividing phase we use two operations stirp and split which are defined in the following.

Definition 3.10. A subgraphS of anL-alphabet, C-alphabet,F-alphabet orE-alphabet grid graph A strips a Hamiltonian path problem PAm, n, s, t, if all of the following four conditions hold:

1Sis even sized and:

iS is a rectangular grid graph; where Am, n is a L-alphabet grid graph Lm, n, a C-alphabet grid graph Cm, n and an E-alphabet grid graph Em, n;

iiS is a L-alphabet graph Lm, n, a rectangular graph R2m−4, n or three rectangular grid graphsR1R3; whereAm, nis aF-alphabet grid graph.

2SandASis a separation ofA;

3s, tAS;

4PAS, s, tis acceptable.

Definition 3.11. Let PAm, n,s,t be a Hamiltonian path problem and p, q be an edge of A, whereAm, n is anL-alphabet,C-alphabet, or F-alphabet grid graph. Then we say p, qsplitsAm,n,s,tif there exists a separation of

(11)

S

LS

s t

a

S

LS

s t

b

CS

S

s t

c Figure 11:a,bA strip ofL3,3,ca strip ofC3,3.

Rq

p q Rp

s

t

a

p q Rp

Rq

s

t

b

p

q Rp

Lq

s

t

c Figure 12:a,bA split ofL3,3,ca split ofC3,3.

1LintoRpandRqsuch that

is, pRpandPRp, s, pis acceptable, iiq, tRqandPRq, q, tis acceptable.

2Fresp.,CintoRpandLqorRqandLpresp.,LqandRpsuch that

is, pRpandPRp, s, pis acceptableors, pLpandPLp, s, pis acceptable, iiq, tLqandPLq, q, tis acceptableorq, tRqandPRq, q, tis acceptable.

In the following, we describe for each alphabet class how the solutions of the subgraphs are merged to construct a Hamiltonian path for the given input graph.

3.1. Hamiltonian Paths inL-Alphabet Grid GraphsLm, n

Since anL-alphabet graphLm, nmay be partitioned into two rectangular grid graphs, then the possible cases for verticessandtare as follows.

(12)

L(m, n)

s

t

R(2m4, n)

a

L(m, n)

s

t

R(2m4, n)

b

s t

R(2m2, n) F(m, n)

c Figure 13:a,bA strip ofF4,3andF3,3,ca strip ofE3,3.

L(m, n)

s t

R(2m4, n)

a

s t

R1

R2

R3 R4

b

s t

R1

R2

R3 R4

c Figure 14:A strip ofF3,3, whens, tR2m−4, n.

Case 1s, tLS. Assume thatLShas a Hamiltonian pathP by the algorithm of12, where LS is a rectangular gird graph. Since S is an even-sized rectangular gird graph, then it has Hamiltonian cycle byLemma 2.2; seeFigure 11a. Therefore, a Hamiltonian path forLm, n, s, tcan be obtained by mergingPand the Hamiltonian cycle ofSas shown in Figure 11b.

Case 2sRpandtRq. In this case, we construct Hamiltonian paths inRpandRqbetween s, pandq, t, respectively; seeFigure 12a. Then a Hamiltonian path forLm, n, s, tcan be obtained by connecting two verticespandqas shown inFigure 12b.

3.2. Hamiltonian Paths inC-Alphabet Grid GraphsCm, n

Similar toL-alphabet graphs since aC-alphabet graphCm, nmay be partitioned into aL- alphabet graphLm, nand a rectangular grid graphR2m−2, n, then the possible cases for verticessandtare as follows.

(13)

Case 1s, tCS. Assume thatCShas a Hamiltonian pathPby theAlgorithm 1, where CSis anL-alphabet gird graphLm, n. Hence, a Hamiltonian path forCm, n, s, tcan be obtained by mergingPand the Hamiltonian cycle ofSas shown inFigure 11c.

Case 2sRpandqLq. A Hamiltonian path can be found asFigure 12c.

3.3. Hamiltonian Paths inF-Alphabet Grid GraphsFm, n ForF-alphabet grid graphs, we consider the following cases.

Case 1s, tFS, whereFSisLm, n. In this case, we construct a Hamiltonian path betweensandtinLm, nby theAlgorithm 1. SinceSis an even-sized rectangular grid graph R2m−4, n, then it has a Hamiltonian cycle byLemma 2.2.

Case 2s, tFS, whereFSisR2m−4, n. We construct a Hamiltonian path betweens andtinR2m−4, nby the algorithm in12. SinceSis an even-sizedL-alphabet grid graph Lm, n, then it has a Hamiltonian cycle byLemma 2.3.

In two cases, by combining the Hamiltonian cycle ofSand the Hamiltonian path ofL orR2m−4, n, a Hamiltonian path betweensandtforFm, nis obtained, see Figures13a and13b.

Case 3Fm, nis odd sized ands, tFS, whereFSisR2m−4, n. In this case,sandt must be white. SinceR2m−4, nis even sized, thensandtare not color compatible inR2m

4, n, seeFigure 14a. Therefore, we repartitionFm, ninto four rectangular grid graphsR1, R2, R3, and R4, such that s, tVR1 andR2,R3, and R4 are even sized, seeFigure 14b where the dotted lines represent the strip. In this case, by combining the Hamiltonian cycles inR2,R3, andR4and the Hamiltonian path ofR1, a Hamiltonian path between sandtfor Fm, n, s, tis obtained, seeFigure 14c.

Case 4 sRp and tLq or sLp and qRq. A Hamiltonian path can be found as Figure 15.

3.4. Hamiltonian Paths inE-Alphabet Grid GraphsEm, n

A Hamiltonian path for anE-alphabet grid graphEm, ncan be found using striping. So we stripEm, nsuch thats, tES, whereESisF-alphabetFm, norC-alphabetCm, n. In this case, we construct a Hamiltonian path in Fm, n or Cm, n by Algorithm 3 or 4. Since S is an even-sized rectangular grid graph R2m−2, n or R2m−4, n, then it has a Hamiltonian cycle by Lemma 2.2. By combining the Hamiltonian cycle of Sand the Hamiltonian path ofForC, a Hamiltonian path betweensandtforEm, nis obtained, see Figure 13c.

Thus, we have the following lemmas.

Lemma 3.12. LetAm, n, s, tbe an acceptable Hamiltonian path problem, andSstrips it, where Am, nis anL-alphabet,C-alphabet,F-alphabet, orE-alphabet grid graph. IfAShas a Hamiltonian path betweensandt, thenAm, n, s, thas a Hamiltonian path betweensandt.

(14)

s t L(m, n)

R(2m4, n)

a

L(m, n)

s t

p q

b

s t

p q

c Figure 15:A split ofF3,3.

procedureLHamiltonianPathLm, n, s, t 1: ifLcan be strippedthen

2: letSbe a strip ofL, whereSis an even-sized rectangular grid graph 3: PRHamiltonianPathLS, s, t

4: D←HamiltonianCycleS 5: returnMergeStripP, D, s, t 6: else

7: letLbe split toRpandRq

8: P1RHamiltonianPathRp, s, p 9: P2RHamiltonianPathRq, q, t 10: returnMergeSplitP1, P2, p, q 11: end if

Algorithm 1:The Hamiltonian path algorithm forL-alphabet grid graphs.

Lemma 3.13. Letp, qbe an edge which splitsPAm, n, s, t. If

i Rp, s, pandRq, q, t, whereAm, nisL-alphabet grid graphLm, n, ii Lq, q, tandRp, s, p, whereAm, nisC-alphabet grid graphCm, n,

iii Rp, s, pandLq, q, torRq, q, tandLp, s, p, whereAm, nisF-alphabet grid graph Fm, n,

have a Hamiltonian path betweens, pandq, t, thenAm, nalso has a Hamiltonian path between sandt.

Since all the proofs presented in this section were constructive, they give us algorithms for finding a Hamiltonian path inL-alphabet,C-alphabet,F-alphabet, andE-alphabet grid graphs. The pseudo-codes of the algorithms are given in Algorithms1,2,3, and4. In these algorithms, HamiltonianCycle is the procedure that finds the Hamiltonian cycle of a strip based on Lemma 2.2 or Lemma 2.3, MergeStrip is a procedure that merges a path and a cycles,MergeCyclesis a procedure that combine two Hamiltonian cycles using two parallel edges ofe1 and e2,MergeSplitis a procedure that connects two paths by simply adding an edge between their end vertices p and q, and R HamiltonianPathis a procedure that finds

(15)

procedureCHamiltonianPathCm, n, s, t 1: ifCcan be strippedthen

2: letSbe a strip ofC, whereSis an even-sized rectangular grid graphR2m−2, n 3: PLHamiltonianPathCS, s, t

4: D←HamiltonianCycleS 5: returnMergeStripP, D, s, t 6: else

7: letCbe splitRpandLq

8: P1RHamiltonianPathRp, s, p 9: P2LHamiltonianPathLq, q, t 10: returnMergeSplitP1, P2, p, q 11: end if

Algorithm 2:The Hamiltonian path algorithm forC-alphabet grid graphs.

procedureFHamiltonianPathFm, n, s, t

1: ifFcan be stripped, whereFm, nis not odd sized ands, t /R2m−4, nthen 2: letSbe a strip ofF

3: PFSHamiltonianPathFS, s, t

4: /FSis aL-alphabet grid graphLm, nor a rectangular grid graphR2m−4, n

/

5: D←HamiltonianCycleS 6: returnMergeStripP, D, s, t 7: else

8: ifFcan be stripped, whereFm, nis odd sized ands, tR2m−4, nthen 9: letSbe a strip ofF, whereSis three rectangular grid graphsR2, R3andR4

10: PRHamiltonianPathR1, s, t 11: c1←HamiltonianCycleR3 12: c2←HamiltonianCycleR4 13: C←MergeCyclesc1, c2 14: D←HamiltonianCycleR2 15: returnMergeStripP, D, C, s, t 16: else

17: letFbe split toRpandLqorLpandRq 18: P1RHamiltonianPathRp, s, p 19: P2LHamiltonianPathLq, q, t 20: returnMergeSplitP1, P2, p, q 21: end if

22: end if

Algorithm 3:The Hamiltonian path algorithm forF-alphabet grid graphs.

a Hamiltonian path in a rectangular grid graph by the algorithm in 12. The algorithm first checks if the input graphAcan be stripped, then stripsAbyS, and recursively finds a Hamiltonian path ofAS. Otherwise, ifAcan be split, then splitsAintoRp andRq Lq

andRporRqandLp, and recursively finds Hamiltonian paths ofRpandRqLqandRporRq

andLp. Then these two Hamiltonian paths are merged into a single path, whereAm, nis anL-alphabet,C-alphabet,F-alphabet, orE-alphabet grid graph.

FromTheorem 3.9and Lemmas3.12and3.13the following theorem holds.

(16)

procedureEHamiltonianPathEm, n, s, t

1: letSbe a strip ofE, whereSis an even-sized rectangular grid graphR2m−2, nor R2m−4, n

2: PESHamiltonianPathES, s, t

3: /ESis aF-alphabet grid graphFm, nor aC-alphabet grid graphCm, n/ 4: D←HamiltonianCycleS

5: returnMergeStripP, D, s, t

Algorithm 4:The Hamiltonian path algorithm forE-alphabet grid graphs.

Theorem 3.14. LetAm, nbe anL-alphabet,C-alphabet,F-alphabet, orE-alphabet grid graph, and sandtbe two distinct vertices of it.Am, nhas Hamiltonian path if and only ifPAm, n, s, tis acceptable.

Theorem 3.14provides necessary and sufficient conditions for the existence of Hamil- tonian paths inL-alphabet,C-alphabet,F-alphabet andE-alphabet grid graphs.

CombiningTheorem 3.14and the Algorithms1,2,3, and4we arrive at the main result.

Theorem 3.15. InL-alphabet,C-alphabet,F-alphabet orE-alphabet grid graphs, a Hamiltonian path between any two verticessandtcan be found in linear time.

Proof. The algorithms divide the problem into some rectangular grid graphs inO1. Then we solve the subproblems in linear time using the linear time algorithm in12. Then the results are merged in timeO1using the method proposed in12.

4. Conclusion and Future Work

In this paper, we presented linear time algorithms for finding a Hamiltonian path inL-alpha- bet, C-alphabet, F-alphabet, and E-alphabet grid graphs between any two given vertices.

Since the Hamiltonian path problem is NP-complete in general grid graphs, it remains open if the problem is polynomially solvable in solid grid graphs.

References

1 R. Diestel,Graph Theory, vol. 173, Springer, New York, NY, USA, 2nd edition, 2000.

2 M. R. Garey and D. S. Johnson,Computers and Intractability, W. H. Freeman and Co., San Francisco, Calif, USA, 1979.

3 P. Damaschke, “Paths in interval graphs and circular arc graphs,”Discrete Mathematics, vol. 112, no.

1–3, pp. 49–64, 1993.

4 L. Du, “A polynomial time algorithm for hamiltonian cyclePath,” inProceedings of the International MultiConference of Engineers and Computer Scientists (IMECS ’10), vol. 1, pp. 17–19, Hong Kong, 2010.

5 R. J. Gould, “Advances on the Hamiltonian problem—a survey,”Graphs and Combinatorics, vol. 19, no.

1, pp. 7–52, 2003.

6 Y. Gurevich and S. Shelah, “Expected computation time for Hamiltonian path problem,”SIAM Journal on Computing, vol. 16, no. 3, pp. 486–502, 1987.

7 S.-S. Kao and L.-H. Hsu, “Spider web networks: a family of optimal, fault tolerant, Hamiltonian bipartite graphs,”Applied Mathematics and Computation, vol. 160, no. 1, pp. 269–282, 2005.

(17)

8 M. S. Rahman and M. Kaykobad, “On Hamiltonian cycles and Hamiltonian paths,”Information Proc- esing Letters, vol. 94, no. 1, pp. 37–41, 2005.

9 F. Luccio and C. Mugnia, “Hamiltonian paths on a rectangular chessboard,” inProceedings of the 16th Annual Allerton Conference, pp. 161–173, 1978.

10 A. Itai, C. H. Papadimitriou, and J. L. Szwarcfiter, “Hamilton paths in grid graphs,”SIAM Journal on Computing, vol. 11, no. 4, pp. 676–686, 1982.

11 C. Zamfirescu and T. Zamfirescu, “Hamiltonian properties of grid graphs,”SIAM Journal on Discrete Mathematics, vol. 5, no. 4, pp. 564–570, 1992.

12 S. D. Chen, H. Shen, and R. Topor, “An efficient algorithm for constructing Hamiltonian paths in meshes,”Parallel Computing. Theory and Applications, vol. 28, no. 9, pp. 1293–1305, 2002.

13 W. Lenhart and C. Umans, “Hamiltonian cycles in solid grid graphs,” inProceedings of the 38th Annual Symposium on Foundations of Computer Science (FOCS ’97), pp. 496–505, 1997.

14 A. N. M. Salman,Contributions to graph theory, Ph.D. thesis, University of Twente, 2005.

15 K. Islam, H. Meijer, Y. Nunez, D. Rappaport, and H. Xiao, “Hamiltonian circuts in hexagonal grid graphs,” inProceedings of the CCCG, pp. 20–22, 2007.

16 V. S. Gordon, Y. L. Orlovich, and F. Werner, “Hamiltonian properties of triangular grid graphs,”Dis- crete Mathematics, vol. 308, no. 24, pp. 6166–6188, 2008.

17 M. Nandi, S. Parui, and A. Adhikari, “The domination numbers of cylindrical grid graphs,”Applied Mathematics and Computation, vol. 217, no. 10, pp. 4879–4889, 2011.

18 F. Keshavarz-Kohjerdi, A. Bagheri, and A. Asgharian-Sardroud, “A linear-time algorithm for the long- est path problem in rectangular grid graphs,”Discrete Applied Mathematics, vol. 160, no. 3, pp. 210–217, 2012.

19 F. Keshavarz-Kohjerdi and A. Bagheri, “An efficient parallel algorithm for the longest path problem in meshes,”http://arxiv.org/abs/1201.4459.

(18)

Submit your manuscripts at http://www.hindawi.com

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Mathematics

Journal of

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Mathematical Problems in Engineering

Hindawi Publishing Corporation http://www.hindawi.com

Differential Equations

International Journal of

Volume 2014

Applied Mathematics

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Probability and Statistics

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Mathematical PhysicsAdvances in

Complex Analysis

Journal of

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Optimization

Journal of

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Combinatorics

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

International Journal of

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Operations Research

Journal of

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Function Spaces

Abstract and Applied Analysis

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

International Journal of Mathematics and Mathematical Sciences

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

The Scientific World Journal

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Algebra

Discrete Dynamics in Nature and Society

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Decision Sciences

Discrete Mathematics

Journal of

Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014 Hindawi Publishing Corporation

http://www.hindawi.com Volume 2014

Stochastic Analysis

International Journal of

Referensi

Dokumen terkait