Mercurial > hg > ltpda
comparison m-toolbox/classes/@history/getNodes.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % GETNODES converts a history object to a nodes structure suitable for plotting as a tree. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: GETNODES converts a history object to a nodes structure suitable | |
5 % for plotting as a tree. | |
6 % | |
7 % CALL: [n,a, nodes] = getNodes(hist, stop_option); | |
8 % | |
9 % INPUT: hist: hisoty-object | |
10 % stop_option: - 'File' ignores the history steps | |
11 % below load-history step | |
12 % - 'Repo' ignores the history steps | |
13 % below retrieve-history step | |
14 % - 'File Repo' both steps above | |
15 % - N maximun depth | |
16 % | |
17 % OUTPUT: n: A vector of parent pointers | |
18 % a: Number of nodes | |
19 % nodes: Struct of the nodes | |
20 % | |
21 % VERSION: $Id: getNodes.m,v 1.25 2011/02/18 16:48:52 ingo Exp $ | |
22 % | |
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
24 | |
25 function varargout = getNodes(varargin) | |
26 | |
27 import utils.const.* | |
28 | |
29 if nargin == 1 | |
30 h = varargin{1}; % history object | |
31 n = []; % init: list of current node values | |
32 pn = 0; % init: current node value | |
33 a = 1; % init: number of nodes | |
34 nodes = []; % init: node structure | |
35 depth = 0; % init: current depth of the tree | |
36 stop_option = 'full'; % stop option | |
37 elseif nargin == 2 | |
38 h = varargin{1}; % history object | |
39 n = []; % init: list of current node values | |
40 pn = 0; % init: current node value | |
41 a = 1; % init: number of nodes | |
42 nodes = []; % init: node structure | |
43 depth = 0; % init: current depth of the tree | |
44 stop_option = varargin{2}; % stop option | |
45 elseif nargin == 7 | |
46 %%% Set inputs | |
47 h = varargin{1}; % history object | |
48 n = varargin{2}; % list of current node values | |
49 pn = varargin{3}; % current node value | |
50 a = varargin{4}; % number of nodes | |
51 nodes = varargin{5}; % node structure | |
52 depth = varargin{6}; % current depth of the tree | |
53 stop_option = varargin{7}; % stop option | |
54 else | |
55 error('### Unknown number of inputs') | |
56 end | |
57 | |
58 max_depth = 1e20; | |
59 depth_stop = ''; | |
60 if isnumeric(stop_option) | |
61 max_depth = stop_option; | |
62 elseif ischar(stop_option) | |
63 depth_stop = stop_option; | |
64 end | |
65 | |
66 n = [n pn]; | |
67 pl = h.plistUsed; | |
68 nodes(a).pn = pn; | |
69 nodes(a).invars = h.methodInvars; | |
70 nodes(a).n = a; | |
71 nodes(a).names = h.methodInfo.mname; | |
72 nodes(a).params = char(pl); | |
73 nodes(a).pl = pl; | |
74 nodes(a).h = history(h); | |
75 utils.helper.msg(msg.OPROC1, 'scanning node %03d [%s]', a, char(nodes(a).names)); | |
76 | |
77 if depth == max_depth | |
78 nodes(a).names = '...'; | |
79 nodes(a).params = ''; | |
80 nodes(a).invars = {}; | |
81 end | |
82 | |
83 % set the current node value to the number of the child | |
84 pn = a-1; | |
85 | |
86 ih = h.inhists; | |
87 | |
88 % Now decide what to do with my children | |
89 if isa(ih, 'history') | |
90 for i=1:numel(ih) | |
91 | |
92 if isa(pl, 'plist') && isparam(pl, 'filename') && ... | |
93 (strcmpi(depth_stop, 'File') || strcmpi(depth_stop, 'File Repo')) | |
94 elseif isa(pl, 'plist') && (isparam(pl, 'conn') || isparam(pl, 'hostname')) && ... | |
95 (strcmpi(depth_stop, 'Repo') || strcmpi(depth_stop, 'File Repo')) | |
96 else | |
97 if depth < max_depth | |
98 a = a + 1; | |
99 [n, a, nodes] = getNodes(ih(i), n, pn+1, a, nodes, depth+1, stop_option); | |
100 end | |
101 end | |
102 | |
103 end | |
104 end | |
105 | |
106 % Set outputs | |
107 varargout{1} = n; | |
108 varargout{2} = a; | |
109 varargout{3} = nodes; | |
110 end | |
111 |