| Wavelet Toolbox | ![]() |
Node index to node depth-position
Syntax
Description
ind2depo is a tree-management utility.
For a tree of order ORD, [D,P] = ind2depo(ORD,N) computes the depths D and the positions P (at these depths D) for the nodes with indices N.
The nodes are numbered from left to right and from top to bottom. The root index is 0.
N must be a column vector of integers (N 
0).
Note that [D,P] = ind2depo(ORD,[D P]).
Examples
% Create initial tree.
ord = 2; t = ntree(ord,3); % Binary tree of depth 3.
t = nodejoin(t,5);
t = nodejoin(t,4);
plot(t)
% Change Node Label from Depth_Position to Index
% (see the plot function).
% List t nodes (index).
aln_ind = allnodes(t)
aln_ind =
0
1
2
3
4
5
6
7
8
13
14
% Switch from index to Depth_Position.
[depth,pos] = ind2depo(ord,aln_ind);
aln_depo = [depth,pos]
aln_depo =
0 0
1 0
1 1
2 0
2 1
2 2
2 3
3 0
3 1
3 6
3 7
See Also
depo2ind
| ilwt2 | intwave | ![]() |
© 1994-2005 The MathWorks, Inc.