comparison toolboxes/FullBNT-1.0.7/GraphViz/draw_dbn.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 function [x, y, h] = draw_dbn(adj, inter, flip_intra, K, labels, node_t, x, y)
2 % DRAW_LAYOUT_DBN Draws a layout for a Dynamical Belief Network
3 %
4 % [<X1, Y1, X2, Y2>] = DRAW_LAYOUT_DBN(INTRA, INTER, <FLIP_FLAG, K, LABELS, ISBOX, X1, Y1>)
5 %
6 % Inputs :
7 % INTRA, INTER : Adjacency matrices
8 % FLIP_FLAG : Transposes the DAG layout obtained from INTRA connections
9 % If X1, Y1 are specified, FLIP_FLAG has no effect.
10 % K : Unfold K times <Default = 2>
11 % LABELS - if -1, we use 1:N*K
12 % Rest : See DRAW_LAYOUT
13 %
14 % Outputs :
15 % Xi, Yi : Coordinates of nodes (for i'th timeslice) on the unit square
16 % H : Object Handles
17 %
18 % Usage Example : draw_layout_dbn(intra, inter, 1);
19 % draw_layout_dbn(intra, inter);
20 %
21 % Note :
22 % See also DRAW_GRAPH
23
24 % Uses : DRAW_GRAPH
25
26 % Change History :
27 % Date Time Prog Note
28 % 17-Apr-2000 1:02 PM ATC Created under MATLAB 5.3.1.29215a (R11.1)
29
30 % ATC = Ali Taylan Cemgil,
31 % SNN - University of Nijmegen, Department of Medical Physics and Biophysics
32 % e-mail : cemgil@mbfys.kun.nl
33
34 N = size(adj,1);
35 if nargin<3,
36 flip_intra = 0;
37 end;
38
39 if nargin<4,
40 K = 2;
41 end;
42
43 if K<2 | K>7, error('2<=K<=7 must hold..'); end;
44
45
46 if nargin<5
47 % labels = cellstr(char(zeros(N,1)+double('+')));
48 % labels = cellstr(int2str((1:N)'));
49 labels = cellstr(char((0:N-1)'+double('a')));
50 end;
51
52 if nargin<6,
53 node_t = zeros(N,1);
54 % node_t = rand(N,1) > 0.5;
55 end;
56
57 if nargin<7,
58 [x1 y1] = make_layout(adj);
59 if flip_intra, tmp = x1; x1 = y1; y1 = tmp; end;
60 end;
61
62 mid = round(K/2);
63
64
65 xi = x1(:)-1;
66 x = [];
67 y = repmat(y1(:), [K 1]);
68 node_t2 = repmat(node_t(:), [K 1]);
69
70 if isa(labels,'double') & labels==-1 % KPM
71 lb = num2strcell(1:N*K);
72 else
73 lb = {};
74 for i=1:K,
75 labels1 = labels(:);
76 if i==mid, str = ''; else str = sprintf('%+d',i-mid); end;
77 for i=1:N,
78 labels1{i} = [labels1{i} '(t' str ')'];
79 end;
80 lb = [lb; labels1(:)];
81 end;
82 end
83
84 dag = zeros(N*K);
85
86 for i=1:K,
87 xi = xi+1;
88 x = [x; xi];
89
90 idx = ((i-1)*N+1):i*N;
91 dag(idx,idx) = adj;
92 if i<K,
93 dag(idx,idx+N) = inter;
94 end;
95 end;
96
97 [x, y, h] = draw_graph(dag, lb, node_t2, x/K, y);
98
99