annotate toolboxes/FullBNT-1.0.7/bnt/inference/static/@jtree_sparse_inf_engine/clq_containing_nodes.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function c = clq_containing_nodes(engine, nodes, fam)
wolffd@0 2 % CLQ_CONTAINING_NODES Find the lightest clique (if any) that contains the set of nodes
wolffd@0 3 % c = clq_containing_nodes(engine, nodes, family)
wolffd@0 4 %
wolffd@0 5 % If the optional 'family' argument is specified, it means nodes = family(nodes(end)).
wolffd@0 6 % (This is useful since clq_ass_to_node is not accessible to outsiders.)
wolffd@0 7 % Returns c=-1 if there is no such clique.
wolffd@0 8
wolffd@0 9 if nargin < 3, fam = 0; else fam = 1; end
wolffd@0 10
wolffd@0 11 if length(nodes)==1
wolffd@0 12 c = engine.clq_ass_to_node(nodes(1));
wolffd@0 13 %elseif fam
wolffd@0 14 % c = engine.clq_ass_to_node(nodes(end));
wolffd@0 15 else
wolffd@0 16 B = engine.cliques_bitv;
wolffd@0 17 w = engine.clique_weight;
wolffd@0 18 clqs = find(all(B(:,nodes), 2)); % all selected columns must be 1
wolffd@0 19 if isempty(clqs)
wolffd@0 20 c = -1;
wolffd@0 21 else
wolffd@0 22 c = clqs(argmin(w(clqs)));
wolffd@0 23 end
wolffd@0 24 end