function P = dtreefillprob(m,n,T,A,C) % for directed trees % the first node is always the root P = zeros(m^n,1); dims = repmat([m],[1 n]); [nodesi,nodesj]=find(T); ne = length(nodesi); if size(A,3) < ne A = repmat(A,[1 1 ne]); end for xind = 1:m^n x = ind2coord(xind,dims); p = C(x(1)); for e=1:length(nodesi) i = nodesi(e); j = nodesj(e); p = p * A(x(j),x(i),e); end P(xind) = p; end return