A = nodeasc(T,N)
nodeasc is a tree-management utility.
A = nodeasc(T,N) returns the indices of all the ascendants of the node N in the tree T where N can be the index node or the depth and position of the node. A is a column vector with A(1) = index of node N.
A = nodeasc(T,N,'deppos') is a matrix, which contains the depths and positions of all ascendants. A(i,1) is the depth of the i-th ascendant and A(i,2) is the position of the i-th ascendant.
The nodes are numbered from left to right and from top to bottom. The root index is 0.
% Create binary tree of depth 3. t = ntree(2,3); t = nodejoin(t,5); t = nodejoin(t,4); plot(t)
% Change Node Label from Depth_Position to Index % (see the plot function).
nodeasc(t,[2 2]) ans = 5 2 0 nodeasc(t,[2 2],'deppos') ans = 2 2 1 1 0 0