Node descendants.
Syntax
D = nodedesc(T,N)
D = nodedesc(T,N,'deppos')
Description
nodedesc is a tree management utility.
D = nodedesc(T,N) returns the indices of all the descendants of the node N in the tree structure T. N can be the index node or the depth and position of node. D is a column vector with D(1) = index of node N.
D = nodedesc(T,N,'deppos') is a matrix that contains the depths and positions of all descendants. D(i,1) is the depth of i-th descendant and D(i,2) is the position of i-th descendant.
Examples
% Create binary tree of depth 3.
t = maketree(2,3);
tt = nodejoin(t,5);
tt = nodejoin(tt,4);
plottree(tt)

% Node descendants.
nodedesc(tt,2)
ans =
2
5
6
13
14
nodedesc(tt,2,'deppos')
ans =
1 1
2 2
2 3
3 6
3 7
nodedesc(tt,[2 2],'deppos')
ans =
2 2
nodedesc(tt,[1 1],'deppos')
ans =
1 1
2 2
2 3
3 6
3 7
nodedesc(tt,[1 1])
ans =
2
5
6
13
14
See Also
maketree, nodeasc, nodepar, wtreemgr
[ Previous | Help Desk | Next ]