function bnet = distribute_evidence(bnet)
% DISTRIBUTE_EVIDENCE Children absorb from parents on the way back from the root
% bnet = distribute_evidence(bnet)

num_cliques = length(bnet.jtree.adj_mat);
for i=1:num_cliques
  n = bnet.jtree.preorder(i);
  cs = children(bnet.jtree.adj_mat, n);
  for j=1:length(cs)
    c = cs(j);
    s = bnet.jtree.sep_index(n,c);
    %fprintf('%d absorbs from %d via %d\n', c, n, s);
    [bnet.jtree.clpot{c}, bnet.jtree.seppot{s}] = ...
	absorb(bnet.jtree.clpot{c}, bnet.jtree.clpot{n}, bnet.jtree.seppot{s});
  end
end
