function pot = mk_potential(members, bnet)
% MK_POTENTIAL Make a potential of the appropriate type on the specified set of nodes.
% pot = mk_potential(members, bnet)

ns = bnet.node_sizes;
switch bnet.jtree.pot_type
  case 'd',
    ns(bnet.observed_nodes) = 1;
    pot = mk_table(members, ns(members));
  case 'm',
    ns(bnet.observed_nodes) = 1;
    pot = mk_max_table(members, ns(members));
  case 'g',
    ns(bnet.observed_nodes) = 0;
    pot = mk_gpot(members, ns(members), 'c');
  case 'cg',
    ns(intersect(bnet.cts_nodes, bnet.observed_nodes)) = 0;
    ns(intersect(bnet.discrete_nodes, bnet.observed_nodes)) = 1;
    dmem = intersect(members, bnet.discrete_nodes);
    cmem = intersect(members, bnet.cts_nodes);
    pot = mk_cgpot(dmem, cmem, ns, 'c');
  otherwise, 
    error(['bad type ' bnet.jtree.pot_type]);
end
