"""Complete B_n vector and tensor-square crystals. Python 3.14, NumPy 2.3.5, Matplotlib 3.10.7. Optional --rank N (default 3). Output basename to CWD; preserves supplied MPLCONFIGDIR. """ import argparse import os import tempfile os.environ.setdefault('MPLCONFIGDIR', tempfile.gettempdir()+'/codex-wiki-matplotlib') import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.patches import Patch from matplotlib.lines import Line2D from collections import deque def crystal(n): labels=[str(i) for i in range(1,n+1)]+['0']+[r'\overline{'+str(i)+'}' for i in range(n,0,-1)] colors=list(range(1,n))+[n,n]+list(range(n-1,0,-1)) N=len(labels) def counts(b,i): e=f=0 while b-e>0 and colors[b-e-1]==i:e+=1 while b+feps: target=(a+1,b) if a',color=color,lw=1.8)) top.text(b+.5,.17,str(colors[b]),ha='center',color=color,fontsize=11) top.set(xlim=(-.5,N-.5),ylim=(-.5,.7));top.axis('off');top.set_title(f'Vector crystal for B{n}: colors label simple roots',fontsize=13) for (a,b),(c,d),i in edges: x0,y0=b,N-1-a;x1,y1=d,N-1-c dx,dy=x1-x0,y1-y0 ax.annotate('',(x1-.24*dx,y1-.24*dy),(x0+.24*dx,y0+.24*dy),arrowprops=dict(arrowstyle='->',lw=1.7,color=palette[(i-1)%len(palette)]),zorder=1) for a in range(N): for b in range(N): ax.scatter(b,N-1-a,s=950,facecolor=fills[components[(a,b)]],edgecolor='#777777',lw=.5,zorder=2) ax.text(b,N-1-a,'$'+labels[a]+r'\otimes'+labels[b]+'$',ha='center',va='center',fontsize=10,zorder=3) handles=[Patch(facecolor=fills[j],label=f'{name}: {sizes[j]} vertices') for j,name in enumerate(['Traceless symmetric square','Exterior square','Trivial component'])] handles += [Line2D([0],[0],color=palette[(i-1)%len(palette)],lw=2,label=f'root color {i}') for i in range(1,n+1)] ax.legend(handles=handles,loc='lower center',bbox_to_anchor=(.5,-.12),ncol=3,fontsize=9) ax.set(xlim=(-.6,N-.4),ylim=(-.6,N-.4));ax.set_aspect('equal');ax.axis('off') ax.set_title(f'Entire tensor-square crystal: {(2*n+1)**2} vertices; first factor changes downward, second rightward',fontsize=12) fig.savefig('paper-4-crystals.png',dpi=135,facecolor='white',transparent=False) plt.close(fig) if __name__=='__main__':main()