function h = treesubij(i,j,w1,w2) global A C T m n % computes hh(i,j) for a tree % find j0, where % j0 is the minimum descendant of i s.t. j0>=j [n,n] = size(T); h = 0; global LEVELS LEVELS = repmat({[]},n,1); Ti = getSubt(T,i); jj = Ti(Ti>=j); if isempty(jj) return end getLevels(T,1,0); j0 = min(jj); levj0 = getLevu(j0); % which nodes are in the ij subtree? if 0 SubTij = []; for vi = 1:length(Ti) v = Ti(vi); lev = getLevu(v); if lev <= levj0 SubTij(end+1) = v; end end SubTij = SubTij(:)'; else % can't just cut those off SubTij = Ti; end %Xinds = SubTij(SubTij>=j0); %Zinds = SubTij((i