Research Article

Hamiltonian Paths in Some Classes of Grid Graphs

Algorithm 2

The Hamiltonian path algorithm for 𝐶 -alphabet grid graphs.
  procedure 𝐶 _HamiltonianPath ( 𝐶 ( 𝑚 , 𝑛 ) , 𝑠 , 𝑡 )
1:  if   𝐶 can be stripped then
2:   let 𝑆 be a strip of 𝐶 , where 𝑆 is an even-sized rectangular grid graph 𝑅 ( 2 𝑚 2 , 𝑛 )
3:    𝑃 𝐿 _HamiltonianPath ( 𝐶 𝑆 , 𝑠 , 𝑡 )
4:    𝐷 HamiltonianCycle ( 𝑆 )
5:   return MergeStrip ( 𝑃 , 𝐷 , 𝑠 , 𝑡 )
6:  else
7:   let 𝐶 be split 𝑅 𝑝 and 𝐿 𝑞
8:    𝑃 1 𝑅 _HamiltonianPath ( 𝑅 𝑝 , 𝑠 , 𝑝 )
9:    𝑃 2 𝐿 _HamiltonianPath ( 𝐿 𝑞 , 𝑞 , 𝑡 )
10:  return MergeSplit ( 𝑃 1 , 𝑃 2 , 𝑝 , 𝑞 )
11:  end  if