Wavelet Toolbox |
Syntax
Description
N = noleaves(T) returns the indices of nonterminal nodes of the tree T (i.e., nodes that are not leaves). N is a column vector.
The nodes are ordered from left to right as in tree T.
N = noleaves(T,'dp
') returns a matrix N, which contains the depths and positions of nonterminal nodes.
N(i,1)
is the depth of i-th nonterminal node andN(i,2)
is the position of i-th nonterminal node.
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 nonterminal nodes (index).
ntnodes_ind = noleaves(t)
ntnodes_ind =
0
1
2
3
6
% List nonterminal nodes (Depth_Position).
ntnodes_depo = noleaves(t,'dp')
ntnodes_depo =
0 0
1 0
1 1
2 0
2 3
See Also
leaves
nodesplt | ntnode |
© 1994-2005 The MathWorks, Inc.