Main Content

nodejoin

Recompose node

    Description

    X = nodejoin(T,N) recomposes node N of the tree T and returns the result as a tree of the same type.

    X = nodejoin(T) is equivalent to X = nodejoin(T,0).

    example

    Examples

    collapse all

    Create a binary tree of depth 3.

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

    Plot the tree.

    fig = plot(t);

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

    Programmatically, in Node Label, change the selected item from Depth_Position to Index.

    plot(t,"setNodeLabel",fig,"Index")

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

    Merge the nodes at indices 4 and 5. Plot the result.

    t = nodejoin(t,5);
    t = nodejoin(t,4);
    fig = plot(t);
    plot(t,"setNodeLabel",fig,"Index")

    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.

    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.

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

    Data Types: double

    Version History

    Introduced before R2006a

    See Also