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 index of the node which will selects which of the other parents to pass through to X.
%
% Note that we do not store the CPT explicitely, since it may be too big.
%
% This node type can only be used when algo = 'pearl'

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
