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