<<"MultiwaySystems/Multiway.m"
MWLoopbackGraphic[hist_,sep_:.4]:=Module{hh,rp,arrows,t1,t2,u={},v,hc,vbeforecount,vaftercount,hcount,k,g={GrayLevel[0],AbsoluteThickness[.25]},r=sep},hh=Sort[v=Complement[#,u];u=Join[u,v];v,MWStringSortQ]&/@Union/@Map[Last,hist,{2}];vaftercount=hcount=Table[0,{Length[hh]}];vbeforecount=Table[1,{Length[hh]}];rp=MapIndexed(#2〚2〛-1)1.2+StringLength[hh〚#2〚1〛,i〛],-4.4(#2〚1〛-1)&,hh,{2};arrows=FlattenTablet1=Position[hh〚y-1〛,hist〚y,x,1〛,1,1];Ift1=={},{},t1=t11,1;t2=Position[hh〚y〛,hist〚y,x,2〛,1,1];Ift2=={},{t2,k}=Catch[Do[If[(t2=Position[hh〚j〛,hist〚y,x,2〛,1,1])!={},Throw[{t2〚1,1〛,j}]],{j,y-1}]];vaftercounty-1++;vbeforecountk++;hc=Max[Take[hcount,{k,y-1}]]+1;Do[hcount〚j〛=hc,{j,k,y-1}];g=Joing,Linerpy-1,t1+StringLength[hh〚y-1,t1〛],-.3,rpy-1,t1+StringLength[hh〚y-1,t1〛],-.3-vaftercounty-1sep+r,Circlerpy-1,t1+StringLength[hh〚y-1,t1〛]-r,-.3-vaftercounty-1sep+r,r,,0,Linerpy-1,t1+StringLength[hh〚y-1,t1〛]-r,-.3-vaftercounty-1sep,{r-sephcount〚y-1〛,rp〚y-1,t1〛〚2〛-.3-vaftercount〚y-1〛sep},Circle{r-sephcount〚y-1〛,r+rp〚y-1,t1〛〚2〛-.3-vaftercount〚y-1〛sep},r,π,,Line[{{-sephcount〚y-1〛,r+rp〚y-1,t1〛〚2〛-.3-vaftercount〚y-1〛sep},{-sephcount〚y-1〛,rp〚k,t2〛〚2〛+1.3+vbeforecount〚k〛sep-r}}],Circle{r-sephcount〚y-1〛,rp〚k,t2〛〚2〛+1.3+vbeforecount〚k〛sep-r},r,,π,Line{r-sephcount〚y-1〛,rp〚k,t2〛〚2〛+1.3+vbeforecount〚k〛sep},rpk,t2+StringLength[hh〚k,t2〛]-r,1.3+vbeforecountksep,Circlerpk,t2+StringLength[hh〚k,t2〛]-r,1.3+vbeforecountksep-r,r,0,;rpk,t2+StringLength[hh〚k,t2〛],1.3+vbeforecountksep-r,rpk,t2+StringLength[hh〚k,t2〛],1.3,t2=t21,1;rpy-1,t1+StringLength[hh〚y-1,t1〛],-.3,rpy,t2+StringLength[hh〚y,t2〛],1.3,{y,2,Length[hist]},{x,1,Length[hist〚y〛]},2;Graphics[{MapThread[rowblock2,{Flatten[hh,1],Flatten[rp,1]}],(Arrow[#1,.5,ArrowStyle->AbsoluteThickness[.25]]&)/@arrows,g},AspectRatio->Automatic]
#2〚2〛-1
∑
i=1
1
2
1
2
1
2
-π
2
1
2
3π
2
π
2
1
2
1
2
π
2
1
2
1
2
1
2
1
2
Show@MWLoopbackGraphic[MWEvolveListT[{"A"->"AB","AB"->"B","B"->"A"},{"A"},5]];
Show@MWLoopbackGraphic[MWEvolveListT[{"ABA""ABBAB","AB""","ABABBB""AAAAABA"},{"ABABAB"},20]];
Show@MWLoopbackGraphic[MWEvolveListT[{"ABA""ABBAB","AB""","ABABBB""AAAAABA"},{"ABABAB"},25]];
Show@MWLoopbackGraphic[MWEvolveListT[{"A""A","A""AA"},{"A"},5]];
Show@MWLoopbackGraphic[MWEvolveListT[{"A""AB","B""A"},{"A"},5]];
Show@MWLoopbackGraphic[MWEvolveListT[{"AA""","BA""ABB","BB""A"},{"BBA"},10]];