function bnet = collect_evidence(bnet)
% COLLECT_EVIDENCE Parents absorb from children on way to root
% bnet = collect_evidence(bnet)

num_cliques = length(bnet.jtree.adj_mat);
for i=1:num_cliques-1
  n = bnet.jtree.postorder(i);
  ps = parents(bnet.jtree.adj_mat, n);
  for j=1:length(ps)
    p = ps(j);
    s = bnet.jtree.sep_index(p,n);
    %fprintf('%d absorbs from %d via %d\n', p, n, s);
    [bnet.jtree.clpot{p}, bnet.jtree.seppot{s}] = ...
	absorb(bnet.jtree.clpot{p}, bnet.jtree.clpot{n}, bnet.jtree.seppot{s});
  end
end


