function bnode = mk_mux_node(bnet, self, gate)
% MK_MUX_NODE Make a node whose conditional distrib. is a multiplexer.
%
% BNODE = MK_MUX_NODE(BNET, SELF, GATE)
% gate is the number of the node which will selects which of the other parents to pass through.

bnode.type = 'mux';
bnode.adjustable = 0;
bnode.self = self;
bnode.parents = parents(bnet.adj_mat, self);
bnode.gate = gate;
bnode.input = setdiff(bnode.parents, gate);
bnode.self_size = bnet.node_sizes(self);
input_sizes = bnet.node_sizes(bnode.input);
assert(isequal(input_sizes, bnode.self_size*ones(size(input_sizes))));
assert(subset([bnode.parents bnode.self], bnet.discrete_nodes));
bnode.nparams = 0; % since deterministic
