nodedesc
Node descendants
Description
nodedesc
is a tree-management utility.
Examples
Node Descendants
Create a binary tree of depth 3.
t = ntree(2,3);
Recompose two of the nodes. Plot the tree.
t = nodejoin(t,5); t = nodejoin(t,4); fig = plot(t);
Programmatically, in Node Label, change the selected item from Depth_Position
to Index
.
plot(t,"setNodeLabel",fig,"Index")
Obtain the indices of the descendants of the node whose index is 2.
nodedesc(t,2)
ans = 5×1
2
5
6
13
14
Obtain the depths and positions of the descendants of the same node.
nodedesc(t,2,"deppos")
ans = 5×2
1 1
2 2
2 3
3 6
3 7
Obtain the depths and positions of the descendants of the node at depth-position (1,0)
.
nodedesc(t,[1 0],"deppos")
ans = 5×2
1 0
2 0
2 1
3 0
3 1
Obtain the indices of the descendants of the same node.
nodedesc(t,[1 0])
ans = 5×1
1
3
4
7
8
Input Arguments
T
— Tree
dtree
object | ntree
object | wptree
object
Tree, specified as a dtree
, ntree
, or wptree
object.
n
— Tree node
integer | 1-by-2 vector
Tree node, specified as a nonnegative integer or a 1-by-2 vector. You can specify the node by either its index or depth and position.
Data Types: double
Output Arguments
D
— Descendants
vector | matrix
Descendants of the node n
, returned as a column
vector of node indices or a two-column matrix containing the depths and
positions of the descendants.
If
D
is a vector, thenD(1)
is the index of the noden
If
D
is a matrix, the ith row ofD
contains the depth and position of the ith descendant. The first row ofD
is the depth and position of the noden
.
Version History
Introduced before R2006a
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)