[191c94]: wavelets / wfbtmanip / depthIndex2NodeNo.m  Maximize  Restore  History

Download this file

100 lines (86 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
function [nodeNo,nodeChildIdx] = depthIndex2NodeNo(d,k,wt)
if(d==0)
nodeNo=0;
nodeChildIdx=0;
return;
end
% find ordered nodes at depth d-1
nodesNo = getNodesInDepth(d,wt);
if(isempty(nodesNo))
error('%s: Depth of the tree is less than given d.',mfilename);
end
% k is index in children of ordered nodes at depth d
nodeNo = zeros(numel(k),1);
nodeChildIdx = zeros(numel(k),1);
chNo = cumsum(cellfun( @(nEl) length(nEl.g),wt.nodes(nodesNo)));
chNoZ = [0;chNo(:)];
for kIdx=1:numel(k)
ktmp = k(kIdx);
idx = find(chNo>ktmp,1);
if isempty(idx)
error('%s: Index k=%i out of bounds.',mfilename,ktmp);
end
nodeNo(kIdx) = nodesNo(idx);
nodeChildIdx(kIdx) = ktmp-chNoZ(idx)+1;
end
% ktemp = k;
% chNo = cellfun( @(nEl) numel(nEl.g),wt.nodes(nodesNo));
% for ii=1:length(nodesNo)
% if(ktemp<chNo(ii))
% nodeChildIdx = ktemp+1;
% nodeNo = nodesNo(ii);
% if mynodeNo~=nodeNo || mynodeChildIdx ~= nodeChildIdx
% error('mas to tu spatne');
% end
% return;
% else
% ktemp = ktemp-chNo(ii);
% end
% end
% error('%s: Index k out of bounds.',mfilename);
function nodd = getNodesInDepth(d,wt)
% find all nodes with d steps to the root ordered
if d==1
% return root
nodd = find(wt.parents==0);
return;
end
nbf = nodesBForder(wt);
nbfTmp = nbf;
tempd = 0;
while tempd<d
nbf(nbfTmp==0) = [];
nbfTmp(nbfTmp==0) = [];
nbfTmp = wt.parents(nbfTmp);
tempd = tempd+1;
end
nodd = nbf(nbfTmp==0);
%
% nbfPar = wt.parents(nbf);
%
% for ii=1:numel(nbf)
%
% end
% nodd = [];
% toGoTrough = {};
%
%
% nodeNo = find(wt.parents==0);
% toGoTrough = cell(d+1,1);
% toGoTrough{1} = nodeNo;
% tempd = 1;
%
%
% while(tempd<d)
%
% for jj=1:length(toGoTrough{tempd})
% actNod = toGoTrough{tempd}(jj);
% childrenIdx = find(wt.children{actNod}~=0);
% ch = wt.children{actNod}(childrenIdx);
% toGoTrough{tempd+1} = [toGoTrough{tempd+1},ch];
% end
%
% tempd = tempd+1;
% end
%
% nodd=toGoTrough{d};

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks