The sequences produced by Paul's procedure
In[5]:= Do[a = Range[q]; b = Subsets[a, {2}];
b = Select[b, IntegerQ[Sqrt[#[[1]] + #[[2]]]] &];
b = GatherBy[b, #[[1]] &]; b = Flatten[b, 1];
b = DirectedEdge @@@ b; g = Graph[b]; g1 = UndirectedGraph[g];
s = FindHamiltonianCycle[g1]; s = Flatten[s]; s = ToString /@ s;
s = StringReplace[s, "\[UndirectedEdge]" .. -> ","];
p = DeleteDuplicates[
Flatten[StringCases[s, RegularExpression["\\d+"]]]];
Print[{q, p}], {q, 32, 40}] // Timing
During evaluation of In[5]:= {32,{1,15,10,26,23,2,14,22,27,9,16,20,29,7,18,31,5,11,25,24,12,13,3,6,30,19,17,32,4,21,28,8}}
During evaluation of In[5]:= {33,{1,15,10,26,23,2,14,22,27,9,16,33,31,18,7,29,20,5,11,25,24,12,13,3,6,30,19,17,32,4,21,28,8}}
During evaluation of In[5]:= {34,{1,8,28,21,15,10,26,23,13,12,24,25,11,5,4,32,17,19,6,30,34,2,14,22,27,9,16,20,29,7,18,31,33,3}}
During evaluation of In[5]:= {35,{1,8,28,21,15,34,2,14,11,25,24,12,13,23,26,10,6,30,19,17,32,4,5,31,18,7,9,27,22,3,33,16,20,29,35}}
During evaluation of In[5]:= {36,{1,8,17,32,4,12,13,36,28,21,15,34,30,19,6,10,26,23,2,14,35,29,20,16,33,3,22,27,9,7,18,31,5,11,25,24}}
During evaluation of In[5]:= {37,{1,24,25,11,14,22,3,33,16,9,27,37,12,13,36,28,8,17,32,4,21,15,34,30,19,6,10,26,23,2,7,18,31,5,20,29,35}}
During evaluation of In[5]:= {38,{1,8,17,32,4,5,31,18,7,9,27,37,12,24,25,11,38,26,23,13,36,28,21,15,10,6,19,30,34,2,14,22,3,33,16,20,29,35}}
During evaluation of In[5]:= {39,{1,24,25,39,10,6,19,30,34,15,21,4,32,17,8,28,36,13,12,37,27,9,7,18,31,5,11,38,26,23,2,14,22,3,33,16,20,29,35}}
During evaluation of In[5]:= {40,{1,24,40,9,27,37,12,13,36,28,8,17,32,4,21,15,34,30,19,6,10,39,25,11,38,26,23,2,14,22,3,33,16,20,5,31,18,7,29,35}}
Out[5]= {0.156001, Null}
have the property, that also the first and the last entry of them sum up to a perfect square. That comes from the hamiltonian cycle searched for in the graph containing only vertices whose node values sum up to a perfect square.
To get rid of that over-doing, one should accept one non-square vertex, then search again for a hamiltonian cycle and cut the cycle by throwing the non-square vertex away.