Main Content

isnode

Existing node test

    Description

    isnode is a tree-management utility.

    r = isnode(t,n) returns 1 (true) for those nodes n that exist in the tree t and 0 (false) otherwise.

    The nodes are numbered from left to right and from top to bottom. The root index is 0.

    example

    Examples

    collapse all

    Create a binary tree of depth 3.

    ord = 2;
    t = ntree(ord,3);

    Merge the nodes with indices 4 and 5. Plot the tree.

    t = nodejoin(t,5);
    t = nodejoin(t,4);
    plot(t)

    Figure contains an axes object and an object of type uimenu. The axes object with title Tree Decomposition contains 21 objects of type line, text.

    Check for the existence of nodes with depth-position equal to (1,0), (3,1), and (4,5).

    n = [1 0;3 1;4 5];
    isnode(t,n)
    ans = 3x1 logical array
    
       1
       1
       0
    
    

    Change the Node Label from Depth_Position to Index to get this figure:

    Check for the existence of the nodes with indices equal to 1, 3, and 25.

    n = [1;3;25];
    isnode(t,n)
    ans = 3x1 logical array
    
       1
       1
       0
    
    

    Input Arguments

    collapse all

    Tree, specified as an ntree, dtree, or wptree object.

    Tree nodes, specified as a column vector that contains indices of the nodes or a matrix that contains the depths and positions of the nodes. If specified as a matrix, n(i,1) and n(i,2) are the depth and position, respectively, of the ith node.

    Data Types: double

    Output Arguments

    collapse all

    True or false result, returned as a 1 or 0 of data type logical. r and n have the same number of rows.

    Version History

    Introduced before R2006a

    See Also

    |

    Go to top of page