Home > classes > @history > getNodes_plot.m

getNodes_plot

PURPOSE ^

GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree.

SYNOPSIS ^

function [n,a,nodes] = getNodes_plot(h, n, pn, a, nodes, depth, MAX_DEPTH)

DESCRIPTION ^

 GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: GETNODES_PLOT converts a history object to a nodes structure
              suitable for plotting as a tree.

 CALL:        [n,a, nodes] = getNodes(hist, [], 0, 1, [], 0, 2);

 OUTPUT:      n:     A vector of parent pointers
              a:     Number of nodes
              nodes: Struct of the nodes

 REMARK:      This version is equivalent to getNodes with the different that
              this function only return the nodes up to the MAX_DEPTH.

 VERSION:     $Id: getNodes_plot.m,v 1.3 2007/12/04 18:16:11 ingo Exp $

 HISTORY:     14-06-07 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [n,a,nodes] = getNodes_plot(h, n, pn, a, nodes, depth, MAX_DEPTH)
0002 % GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: GETNODES_PLOT converts a history object to a nodes structure
0007 %              suitable for plotting as a tree.
0008 %
0009 % CALL:        [n,a, nodes] = getNodes(hist, [], 0, 1, [], 0, 2);
0010 %
0011 % OUTPUT:      n:     A vector of parent pointers
0012 %              a:     Number of nodes
0013 %              nodes: Struct of the nodes
0014 %
0015 % REMARK:      This version is equivalent to getNodes with the different that
0016 %              this function only return the nodes up to the MAX_DEPTH.
0017 %
0018 % VERSION:     $Id: getNodes_plot.m,v 1.3 2007/12/04 18:16:11 ingo Exp $
0019 %
0020 % HISTORY:     14-06-07 M Hewitson
0021 %                 Creation
0022 %
0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0024 
0025 VERSION  = '$Id: getNodes_plot.m,v 1.3 2007/12/04 18:16:11 ingo Exp $';
0026 
0027 % Check if this is a call for parameters
0028 if nargin == 2
0029   if isa(h, 'history') && ischar(n)
0030     in = char(n);
0031     if strcmp(in, 'Params')
0032       n = plist;
0033       return
0034     elseif strcmp(in, 'Version')
0035       n = VERSION;
0036       return
0037     end
0038   end
0039 end
0040 
0041 % set my node to next number
0042 nn = get(h,'n');
0043 if nn<0
0044   h = set(h, 'n', a);
0045 end
0046 
0047 % set my parent node
0048 nn = get(h,'pn');
0049 if nn<0
0050   h = set(h, 'pn', pn);
0051   n = [n pn];
0052   nodes(a).pn     = pn;
0053   nodes(a).invars = get(h, 'invars');
0054   nodes(a).n      = get(h, 'n');
0055   nodes(a).names  = get(h, 'name');
0056   nodes(a).params = char(get(h, 'plist'));
0057   nodes(a).pl     = get(h, 'plist');
0058 
0059   if depth == MAX_DEPTH
0060     nodes(a).names  = '...';
0061     nodes(a).params = '';
0062     nodes(a).invars = {};
0063   end
0064 
0065 end
0066 
0067 % I need my parent node
0068 pn = get(h, 'n');
0069 
0070 % get my children nodes
0071 ihs = get(h, 'inhists');
0072 
0073 % Now decide what to do with my children
0074 if isa(ihs, 'history')
0075   for i=1:length(ihs)
0076     % get child number
0077     nn = get(ihs(i), 'n');
0078     % if this child is not set
0079     if nn < 0
0080       if depth < MAX_DEPTH
0081 
0082         % set it
0083         a = a + 1;
0084         [n,a, nodes] = getNodes_plot(ihs(i), n, pn, a, nodes, depth+1, MAX_DEPTH);
0085 
0086       end
0087     else % else go back to my parent
0088       [n,a, nodes] = getNodes_plot(h, n, get(h,'pn'), a, nodes, depth, MAX_DEPTH);
0089     end
0090   end
0091 
0092 end
0093

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003