Check if nodes are terminal nodes.
Syntax
R = istnode(T,N)
Description
istnode is a tree management utility.
R = istnode(T,N) returns ranks (in left to right terminal nodes ordering) for terminal nodes N belonging to the tree structure T and 0's for others.
N can be a column vector containing the indices of nodes or a matrix that contains the depths and positions of nodes.
In the last case, N(i,1) is the depth of i-th node and N(i,2) is the position of i-th node.
The nodes are numbered from left to right and from top to bottom. The root index is 0.
Examples
% Create initial tree.
ord = 2;
t = maketree(ord,3); % binary tree of depth 3.
tt = nodejoin(t,5);
tt = nodejoin(tt,4);
plottree(tt)
% Find terminal nodes and return indices for terminal
% nodes in the tree structure.
istnode(tt,[14])
ans =
6
istnode(tt,[15])
ans =
0
istnode(tt,[1;7;14;25])
ans =
0
1
6
0
istnode(tt,[1 0;3 1;4 5])
ans =
0
2
0
See Also
isnode, maketree, wtreemgr
[ Previous | Help Desk | Next ]