function T = bintree(L) % a binary tree on L levels n = 2^(L) - 1; global T0 L0 n0 T0 = zeros(n); L0 = L; n0 = 1; subt(1,1); T = T0; % order tree properly sig = lexordtree(T); sig = invperm(sig); T1 = T*0; [nodesi,nodesj]=find(T); ne = length(nodesi); for e=1:ne i = nodesi(e); j = nodesj(e); T1(sig(i),sig(j)) = 1; end T = T1; return function subt(i,l) global L0 T0 n0 if l