Node ascendants.
Syntax
A = nodeasc(T,N)
A = nodeasc(T,N,'deppos')
Description
nodeasc is a tree management utility.
A = nodeasc(T,N) returns the indices of all the ascendants of the node N in the tree structure T. N can be the index node or the depth and position of node. A is a column vector with A(1) = index of node N.
A = nodeasc(T,N,'deppos') is a matrix that contains the depths and positions of all ascendants. A(i,1) is the depth of i-th ascendant and A(i,2) is the position of i-th ascendant.
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 =
7
3
1
0
nodedesc(tt,2,'deppos')
ans =
nodeasc(tt,[2 2])
ans =
5
2
0
nodeasc(tt,[2 2],'deppos')
ans =
2 2
1 1
0 0
See Also
maketree, nodedesc, nodepar, wtreemgr
[ Previous | Help Desk | Next ]