Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

isnode

Existing node test

Syntax

R = isnode(T,N)

Description

isnode is a tree-management utility.

R = isnode(T,N) returns 1's for nodes N, which exist in the tree 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 the i-th node and N(i,2) is the position of the 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 = 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).

% Check node index. 
isnode(t,[1;3;25])

ans =
    1 
    1 
    0

% Check node Depth_Position.
isnode(t,[1 0;3 1;4 5])

ans =
    1 
    1 
    0

See Also

|

Introduced before R2006a

Was this topic helpful?