TreeChildren

TreeChildren[tree]

extracts the children of the root of the Tree object tree.

TreeChildren[tree,pos]

extracts the children of subtrees at positions specified by pos.

Details

  • In TreeChildren[tree,pos], tree should be a valid Tree object.
  • The position specifications used by TreeChildren have the same form as those returned by TreePosition and used in functions such as TreeExtract.
  • The following positions can be used for pos:
  • ithe i^(th) child
    -ithe i^(th) child from the end
    {i1,i2,}the list of children at positions i1, i2,
    m;;nchildren m through n
    TreeLevel[levelspec]the subtrees on levels specified by levelspec
    TreeCases[pattern]the subtrees with data matching pattern
    TreeSelect[crit]the subtrees for which crit gives True
    TreeDatathe data in the tree
  • TreeChildren[tree,All] is equivalent to TreeChildren[tree,TreeLevel[{1}]].
  • In TreeChildren position specifications, position 0 is equivalent to TreeData.

Examples

open allclose all

Basic Examples  (4)

Extract the children subtrees in a tree:

Extract the children of the subtree at position {3}:

Extract the children of an arbitrary subtree:

Extract the children of multiple subtrees:

Scope  (6)

Extract the children of a subtree:

Extract multiple subtrees:

Extract a span of children:

Extract using different specifications:

Extract children of subtrees matching a data pattern:

Extract the children of subtrees with exactly two children:

Properties & Relations  (1)

Extract the children of subtrees given by TreePosition:

Possible Issues  (1)

TreeChildren[tree,{}] returns an empty list because the list of positions is empty:

TreeChildren[tree,{{}}] extracts the children of the subtree at position {}, which is the root:

Wolfram Research (2021), TreeChildren, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeChildren.html.

Text

Wolfram Research (2021), TreeChildren, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeChildren.html.

BibTeX

@misc{reference.wolfram_2021_treechildren, author="Wolfram Research", title="{TreeChildren}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/TreeChildren.html}", note=[Accessed: 26-September-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_treechildren, organization={Wolfram Research}, title={TreeChildren}, year={2021}, url={https://reference.wolfram.com/language/ref/TreeChildren.html}, note=[Accessed: 26-September-2021 ]}

CMS

Wolfram Language. 2021. "TreeChildren." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TreeChildren.html.

APA

Wolfram Language. (2021). TreeChildren. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeChildren.html