function P = dtreefillprob1(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); 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(i,j,x(j),x(i)); end P(xind) = p; end return