function h = dtreehijub(A,C,T,m,n,i,j) dpi = dpath(T,1,i); dep_i = length(dpi) %[dp,j0] = dpath(T,i,j); %if ~j0 % h = 1e-9; % return %end %dpj = dpath(T,1,j0); %dep_j = length(dpj) dpj = dpath(T,1,j); dep_j = length(dpj) %if dep_i > dep_j % keyboard %end [w,levels,ll] = treewidth(T); h = 1; for d = dep_i+1:dep_j levd = levels{d}; thh = []; for v = levd u = find(T(:,v)); Auv = reshape(A(u,v,:,:),[m m]); thh(end+1) = gettha(Auv); end h = h * inclexcl(thh); end return function th = gettha(A) [n,n] = size(A); th = 0; for i=1:n for j=i+1:n x = A(:,i); y = A(:,j); d = .5*sum(abs(x-y)); if d>th th=d; end end end return function [dp,j0] = dpath(T,i,j) % bounds hh(i,j) for a tree % find j0, where % j0 is the minimum descendant of i s.t. j0>=j Ti = getSubt(T,i); jj = Ti(Ti>=j); if isempty(jj) dp = []; j0 = 0; else j0 = min(jj); dp = parentseq(T,j0,i); end return function pseq = parentseq(T,u,r) v = u; el = 0; pseq = [u]; while v~=r el = el+1; rents = find(T(:,v)); v = rents; pseq = [v pseq]; end return function sT = getSubt(T,v) % a list of v's descendents in T % includes v itself global SUBT SUBT = []; Pi(T,v); sT = SUBT; return function Pi(T,v) global SUBT SUBT(end+1) = v; vkids = find(T(v,:)); for vi=1:length(vkids) v1 = vkids(vi); Pi(T,v1); end