function T = randtree(n) T = zeros(n); for i=2:n % attach each node to a random one in the tree jj = randperm(i-1); j = jj(1); T(i,j) = 1; end T = T + T'; return