annotate toolboxes/FullBNT-1.0.7/graph/triangulate_test.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 % Test the code using the dag in Fig 1 of Jensen, Jensen, Dittmer,
wolffd@0 2 % "From influence diagrams to junction trees", UAI 94
wolffd@0 3
wolffd@0 4 % By reverse enginering Fig 2, we infer that the following arcs should
wolffd@0 5 % be absent from the original dag: b->d1, e->d2, f->d2, g->d4
wolffd@0 6 a=1; b=2; d1=3; c=4; d=5; e=6; f=7; g=8; d2=9; d4=10; i=11; h=12; d3=13; l=14; j=15; k=16;
wolffd@0 7 dag=zeros(16);
wolffd@0 8 dag(a,c)=1;
wolffd@0 9 %dag(b,[c d d1])=1;
wolffd@0 10 dag(b,[c d])=1;
wolffd@0 11 dag(d1,d)=1;
wolffd@0 12 dag(c,e)=1;
wolffd@0 13 dag(d,[e f])=1;
wolffd@0 14 %dag(e,[g d2])=1;
wolffd@0 15 dag(e,[g])=1;
wolffd@0 16 %dag(f,[d2 h])=1;
wolffd@0 17 dag(f,[h])=1;
wolffd@0 18 %dag(g,[d4 i])=1;
wolffd@0 19 dag(g,[i])=1;
wolffd@0 20 dag(d2,i)=1;
wolffd@0 21 dag(d4,l)=1;
wolffd@0 22 dag(i,l)=1;
wolffd@0 23 dag(h,[j k])=1;
wolffd@0 24 dag(d3,k)=1;
wolffd@0 25
wolffd@0 26
wolffd@0 27 [MG, moral_edges] = moralize(dag);
wolffd@0 28 MG(j,k)=1; MG(k,j)=1; % simulate having a common utility child
wolffd@0 29 % MG now equals fig 2
wolffd@0 30 order = [l j k i h a c d d4 g d3 d2 f e d1 b];
wolffd@0 31 [MTG, cliques, fill_ins] = triangulate(MG, order);
wolffd@0 32 % MTG equals fig 3
wolffd@0 33 ns = 2*ones(1,16);
wolffd@0 34 [jtree, root, cliques2] = mk_strong_jtree(cliques, ns, order, MTG);
wolffd@0 35 jtree2 = mk_rooted_tree(jtree, root);
wolffd@0 36 % jtree2 equals fig 4, with their arrows reversed