Home > classes > @history > getNodes.m

getNodes

PURPOSE ^

GETNODES converts a history object to a nodes structure suitable for

SYNOPSIS ^

function [n,a,nodes] = getNodes(h, n, pn, a, nodes)

DESCRIPTION ^

 GETNODES converts a history object to a nodes structure suitable for
 plotting as a tree.
 
 M Hewitson 02-02-07
 
 $Id: getNodes.html,v 1.1 2007/06/08 14:15:05 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [n,a,nodes] = getNodes(h, n, pn, a, nodes)
0002 
0003 % GETNODES converts a history object to a nodes structure suitable for
0004 % plotting as a tree.
0005 %
0006 % M Hewitson 02-02-07
0007 %
0008 % $Id: getNodes.html,v 1.1 2007/06/08 14:15:05 hewitson Exp $
0009 %
0010 
0011 % set my node to next number
0012 nn = get(h,'n');
0013 if nn<0
0014   h = set(h, 'n', a);
0015 end
0016 
0017 % set my parent node
0018 nn = get(h,'pn');
0019 if nn<0
0020   h = set(h, 'pn', pn);
0021   n = [n pn];
0022   nodes(a).pn     = pn;
0023   nodes(a).invars = get(h, 'invars');
0024   nodes(a).n      = get(h, 'n');
0025   nodes(a).names  = get(h, 'name');
0026   nodes(a).params = char(get(h, 'plist'));  
0027   nodes(a).pl     = get(h, 'plist');
0028 end
0029 % disp(['node: ' num2str(get(h, 'pn'))]);
0030 
0031 % I need my parent node
0032 pn = get(h, 'n');
0033   
0034 % get my children nodes
0035 ihs = get(h, 'inhists');
0036 
0037 % Now decide what to do with my children
0038 if isa(ihs, 'history')
0039   for i=1:length(ihs)
0040     % get child number
0041     nn = get(ihs(i), 'n');
0042     % if this child is not set
0043     if nn < 0
0044       % set it
0045       a = a + 1;
0046       [n,a, nodes] = getNodes(ihs(i), n, pn, a, nodes);
0047     else % else go back to my parent
0048       [n,a, nodes] = getNodes(h, n, get(h,'pn'), a, nodes);      
0049     end
0050   end
0051 end
0052

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003