Out[]=
The above animation is a depth-first scan of the pattern block growth tree. In principle, the frame sequencing should be possible to calculate using DepthFirstScan. In practice, I couldn’t figure out how DepthFirstScan would work for this use case. It was quicker for me just to code up another backtracking algorithm along the lines of DepthFirstSearch.
The following function ascends from root to leaf, until it hits a leaf. When it does hit a leaf, it then descends back toward the root until it can move upward again. Through the entire while loop, a “cursor” visits every node, usually more than once. Whenever the cursor changes from one node to the next, its position is stored in a linear memory structure. The loop completes when the cursor returns to the root node, and then the sequential list of nodes is retrieved from memory and returned as the result.
In[]:=
DepthFirstPath[graph_,inits_]:=Module[{dag,state,cursor,outs,max=0,asc=True,res},dag=graph;state=Association[0->inits];res=Reap[While[!SameQ[state,Association[]],If[asc,cursor=First[state[max],True];If[TrueQ[cursor],KeyDropFrom[state,max--];asc=False,Sow[cursor];outs=VertexOutComponent[dag,cursor,{1}];If[SameQ[Length[outs],0],Sow[First[state[max-1]]];state[max]=Rest[state[max]],state[++max]=outs];];,state[max]=Rest[state[max]];If[SameQ[Length[state[max]],0],Sow[First[state[max-1]]];KeyDropFrom[state,max--];,Sow[First[state[max-1]]];asc=True]]]];DeleteCases[res[[2,1]],"KeyAbsent"]]
In[]:=
indg=;
order=DepthFirstPath[indg,First[ResourceFunction["VertexStratify"][indg]]];
In[]:=
ListPlot@order
Out[]=
And we can see that some nodes have a high branching ratio and must be revisited 50 or 60 times:
In[]:=
ListPlot[Select[Sort[Counts[order]],#!=1&]]
Out[]=