wolffd@0: function [x, y, h] = draw_dbn(adj, inter, flip_intra, K, labels, node_t, x, y) wolffd@0: % DRAW_LAYOUT_DBN Draws a layout for a Dynamical Belief Network wolffd@0: % wolffd@0: % [] = DRAW_LAYOUT_DBN(INTRA, INTER, ) wolffd@0: % wolffd@0: % Inputs : wolffd@0: % INTRA, INTER : Adjacency matrices wolffd@0: % FLIP_FLAG : Transposes the DAG layout obtained from INTRA connections wolffd@0: % If X1, Y1 are specified, FLIP_FLAG has no effect. wolffd@0: % K : Unfold K times wolffd@0: % LABELS - if -1, we use 1:N*K wolffd@0: % Rest : See DRAW_LAYOUT wolffd@0: % wolffd@0: % Outputs : wolffd@0: % Xi, Yi : Coordinates of nodes (for i'th timeslice) on the unit square wolffd@0: % H : Object Handles wolffd@0: % wolffd@0: % Usage Example : draw_layout_dbn(intra, inter, 1); wolffd@0: % draw_layout_dbn(intra, inter); wolffd@0: % wolffd@0: % Note : wolffd@0: % See also DRAW_GRAPH wolffd@0: wolffd@0: % Uses : DRAW_GRAPH wolffd@0: wolffd@0: % Change History : wolffd@0: % Date Time Prog Note wolffd@0: % 17-Apr-2000 1:02 PM ATC Created under MATLAB 5.3.1.29215a (R11.1) wolffd@0: wolffd@0: % ATC = Ali Taylan Cemgil, wolffd@0: % SNN - University of Nijmegen, Department of Medical Physics and Biophysics wolffd@0: % e-mail : cemgil@mbfys.kun.nl wolffd@0: wolffd@0: N = size(adj,1); wolffd@0: if nargin<3, wolffd@0: flip_intra = 0; wolffd@0: end; wolffd@0: wolffd@0: if nargin<4, wolffd@0: K = 2; wolffd@0: end; wolffd@0: wolffd@0: if K<2 | K>7, error('2<=K<=7 must hold..'); end; wolffd@0: wolffd@0: wolffd@0: if nargin<5 wolffd@0: % labels = cellstr(char(zeros(N,1)+double('+'))); wolffd@0: % labels = cellstr(int2str((1:N)')); wolffd@0: labels = cellstr(char((0:N-1)'+double('a'))); wolffd@0: end; wolffd@0: wolffd@0: if nargin<6, wolffd@0: node_t = zeros(N,1); wolffd@0: % node_t = rand(N,1) > 0.5; wolffd@0: end; wolffd@0: wolffd@0: if nargin<7, wolffd@0: [x1 y1] = make_layout(adj); wolffd@0: if flip_intra, tmp = x1; x1 = y1; y1 = tmp; end; wolffd@0: end; wolffd@0: wolffd@0: mid = round(K/2); wolffd@0: wolffd@0: wolffd@0: xi = x1(:)-1; wolffd@0: x = []; wolffd@0: y = repmat(y1(:), [K 1]); wolffd@0: node_t2 = repmat(node_t(:), [K 1]); wolffd@0: wolffd@0: if isa(labels,'double') & labels==-1 % KPM wolffd@0: lb = num2strcell(1:N*K); wolffd@0: else wolffd@0: lb = {}; wolffd@0: for i=1:K, wolffd@0: labels1 = labels(:); wolffd@0: if i==mid, str = ''; else str = sprintf('%+d',i-mid); end; wolffd@0: for i=1:N, wolffd@0: labels1{i} = [labels1{i} '(t' str ')']; wolffd@0: end; wolffd@0: lb = [lb; labels1(:)]; wolffd@0: end; wolffd@0: end wolffd@0: wolffd@0: dag = zeros(N*K); wolffd@0: wolffd@0: for i=1:K, wolffd@0: xi = xi+1; wolffd@0: x = [x; xi]; wolffd@0: wolffd@0: idx = ((i-1)*N+1):i*N; wolffd@0: dag(idx,idx) = adj; wolffd@0: if i