function bnet = initialize_cutset(bnet)
% INITIALIZE_CUTSET Make some auxiliary datastructures needed by the cutset algorithm.
% bnet = initialize_cutset(bnet)

num_nodes = length(bnet.adj_mat);
bnet.cutset.absorbed_edges = zeros(num_nodes);
original_dag = bnet.adj_mat;
dag2 = bnet.adj_mat;
cutset = bnet.cutset.cutset_nodes;
for i=cutset
  for c=children(bnet.adj_mat, i)
    dag2(i,c) = 0;
    d = dfs(dag2, i, 0); 
    if d(c) > 0 % there is an undirected path from i to c other than the i->c edge
      bnet.cutset.absorbed_edges(i,c) = 1;
    else
      dag2(i,c) = 1;
    end
  end
end
assert(connected_graph(dag2, 0));
bnet.cutset.dag = dag2;
bnet.adj_mat = dag2;
bnet.pearl = initialize_pearl(bnet);
bnet.adj_mat = original_dag;
bnet.cutset.initialized = 1;
