ntree

NTREE constructor

Syntax

T = ntree(ORD,D)
T = ntree
T = ntree(2,0)
T = ntree(ORD)
T = ntree(ORD,0)
T = ntree(ORD,D,S)
T = ntree(ORD,D,S,U)

Description

T = ntree(ORD,D) returns an NTREE object, which is a complete tree of order ORD and depth D.

T = ntree is equivalent to T = ntree(2,0).

T = ntree(ORD) is equivalent to T = ntree(ORD,0).

With T = ntree(ORD,D,S) you can set a "split scheme" for nodes. The split scheme field S is a logical array of size ORD by 1.

The root of the tree can be split and it has ORD children. You can split the j-th child if S(j) = 1.

Each node that you can split has the same property as the root node.

With T = ntree(ORD,D,S,U) you can, in addition, set a userdata field.

Inputs can be given in another way:

T = ntree('order',ORD,'depth',D,'spsch',S,'ud',U). For "missing" inputs the defaults are ORD = 2 , D = 0 , S = ones([1:ORD]) , U = {}.

[T,NB] = ntree( ... ) returns also the number of terminal nodes (leaves) of T.

For more information on object fields, type help ntree/get.

Class NTREE (Parent class: WTBO)

Fields

wtbo

Parent object

order

Tree order

depth

Tree depth

spsch

Split scheme for nodes

tn

Column vector with terminal node indices

Examples

% Create binary tree (tree of order 2) of depth 3.
t2 = ntree(2,3);

% Plot tree t2.
plot(t2)

% Create a quadtree (tree of order 4) of depth 2.
t4 = ntree(4,2,[1 1 0 1]);

% Plot tree t4.
plot(t4)

% Split and merge some nodes using the gui
% generated by plot (see the plot function).
% The figure becomes:

See Also

Was this topic helpful?