0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % HIST2DOT converts a history object to a 'DOT' file suitable for processing with graphviz
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: HIST2DOT converts a history object to a 'DOT' file suitable for
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % processing with graphviz (www.graphviz.org).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % CALL: hist2dot(h, 'foo.dot');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % INPUT: h - history object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % foo.dot - file name to view the graphic with the programm
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % graphviz
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % VERSION: $Id: hist2dot.m,v 1.16 2011/02/18 16:48:52 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 function varargout = hist2dot(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 %%% Set inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 h = varargin{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 filename = varargin{2};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 if nargin > 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 if isa(varargin{3}, 'plist')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 pl = varargin{3};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 pl = combine(pl, getDefaultPlist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 stop_option = find(pl, 'stop_option');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 %%% Write .dot file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 fd = fopen(filename, 'w+');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 %%% write header
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 fprintf(fd, 'digraph G \n{\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 old = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 if old
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 [n,a, nodes] = getNodes(h, stop_option);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 nodesWritten = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 %%% Write block set
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 fprintf(fd, 'end [label="END"];\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 for j=1:length(nodes)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 node = nodes(j);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 % tag =
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 if ~containsNodeArray(nodesWritten, node)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % wrap label
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % Do some command substitution
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 fcn = node.names;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 shape = 'rectangle';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 fsize = 12;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 extras = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 wstr = utils.prog.wrapstring([fcn char(node.params)], 25);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 ss = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 for s=wstr
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 ss = [ss '\n' char(s)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 ss = ss(3:end);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 fprintf(fd, '%s [%s fontsize=%d shape=%s label="%s"];\n', nodeName(node), extras, fsize, shape, ss);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 nodesWritten = [nodesWritten {node.h.UUID}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 %%% Write node list
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 fprintf(fd, '\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 fprintf(fd, '\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 nodesConnected = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 for j=length(nodes):-1:1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 % disp('----------------')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 node = nodes(j);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 % node.h
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 % if ~arrayContainsElement(nodesConnected, node.pn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 if node.pn > 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 dst = nodes(node.pn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 fprintf(fd, '%s -> %s; # %d\n', nodeName(node), nodeName(dst), dst.pn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 % nodesConnected = [nodesConnected {node.h.UUID}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 fprintf(fd, '%s -> end;\n', nodeName(node));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 nodesConnected = [nodesConnected node.pn];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 % disp('----------------')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 % Get unique history nodes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 [hists, links] = getHists(h, [], []);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 % Now write history blocks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 fprintf(fd, 'end [label="END"];\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 for ll=1:numel(hists)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 hist = hists(ll);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 % wrap label
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 % Do some command substitution
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 fcn = hist.methodInfo.mname;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 shape = 'rectangle';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 fsize = 12;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 extras = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 wstr = utils.prog.wrapstring([fcn char(hist.plistUsed)], 25);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 ss = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 for s=wstr
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 ss = [ss '\n' char(s)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 ss = ss(3:end);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 fprintf(fd, '%s [%s fontsize=%d shape=%s label="%s"];\n', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 nodeName(hist), ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 extras, fsize, shape, ss);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 fprintf(fd, '\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 fprintf(fd, '\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 % Now write links
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 for kk=1:numel(links)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 fprintf(fd, '%s', links{kk});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 fprintf(fd, '%s -> end;\n', nodeName(h));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 %%% close
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 fprintf(fd, '}\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 %%% Close
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 fclose(fd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 function [hists, links] = getHists(obj, links, hists)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 if isa(obj, 'history') && ~arrayContainsObjects(hists, obj)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 pl = obj.plistUsed;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 for kk=1:pl.nparams
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 val = pl.params(kk).getVal();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 if isa(val, 'history')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 for jj=1:numel(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 if ~arrayContainsObjects(hists, val(jj))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 [hists, links] = getHists(val(jj), links, hists);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 % write link
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 l = sprintf('%s -> %s;\n', nodeName(val(jj)), nodeName(obj));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 links = [links {l}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 hists = [hists obj];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 if isprop(obj, 'hist')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 if ~arrayContainsObjects(hists, obj.hist)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 [hists, links] = getHists(obj.hist, links, hists);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 if isprop(obj, 'inhists')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 for kk=1:numel(obj.inhists)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 if ~arrayContainsObjects(hists, obj.inhists(kk))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 [hists, links] = getHists(obj.inhists(kk), links, hists);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 % write link
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 l = sprintf('%s -> %s;\n', nodeName(obj.inhists(kk)), nodeName(obj));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 links = [links {l}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 function res = arrayContainsObjects(array, obj)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 res = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 for kk=1:numel(array)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 if strcmp(array(kk).UUID, obj.UUID)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 res = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 function nn = nodeName(node)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 nn = ['node_' strrep(node.UUID, '-', '_')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 function res = arrayContainsElement(array, element)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 res = any(array == element);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 % res = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 % for kk=1:numel(array)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 % if strcmp(array(kk).UUID, element.UUID)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 % res = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 % break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 function res = containsNodeArray(nodes, node)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 x = @(c)(strcmp(c, node.h.UUID));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 res = any(cellfun(x, nodes));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 % res = cellfun('strcmp', nodes, node);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 % res = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 % for kk=1:numel(nodes)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 % if strcmp(nodes{kk}, node.h.UUID)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 % res = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 % break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 % Local Functions %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 % FUNCTION: getDefaultPlist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 % DESCRIPTION: Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 function plo = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 plo = plist('stop_option', 'full');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255
|