annotate toolboxes/FullBNT-1.0.7/graph/test_strong_root.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 strong = test_strong_root(jtree,cliques,dnodes,root)
wolffd@0 2 % This function tests, whether root is a strong root of jtree.
wolffd@0 3 % The following parameters are used
wolffd@0 4 % Input:
wolffd@0 5 % jtree An matrix with two colums. jtree(i,j) == jtree(j,i) is 1 if node
wolffd@0 6 % i is connected with node j
wolffd@0 7 % cliques Cells which contain the nodes in each clique
wolffd@0 8 % dnodes An array with the discrete nodes of the juntion tree.
wolffd@0 9 % root It is tested whether root is the strong root of the junction tree
wolffd@0 10 % Output:
wolffd@0 11 % strong The output is 1 if root is the strong root of the junction tree jtree.
wolffd@0 12 % Please note, that the running intersection property is not tested.
wolffd@0 13 if isempty(dnodes)
wolffd@0 14 strong = 1;
wolffd@0 15 return;
wolffd@0 16 end
wolffd@0 17
wolffd@0 18 children = find(jtree(root,:)==1);
wolffd@0 19 i = 1;
wolffd@0 20 strong = 1;
wolffd@0 21 while (i <= length(children)) & (strong==1)
wolffd@0 22 child = children(i);
wolffd@0 23 jtree(child,root) = 0;
wolffd@0 24 jtree(root,child) = 0;
wolffd@0 25 sep = myintersect(cliques{child},cliques{root});
wolffd@0 26 diff = mysetdiff(cliques{child},cliques{root});
wolffd@0 27 if (mysubset(sep,dnodes) | isempty(myintersect(diff,dnodes)))
wolffd@0 28 strong = test_strong_root(jtree,cliques,dnodes,child);
wolffd@0 29 else
wolffd@0 30 strong = 0;
wolffd@0 31 end;
wolffd@0 32 i = i+1;
wolffd@0 33 end
wolffd@0 34