TreeSelect

TreeSelect[tree,crit]

picks out all subtrees treei of tree for which crit[treei] is True.

TreeSelect[tree,crit,n]

picks out the first n subtrees for which crit[treei] is True.

TreeSelect[crit]

represents an operator form of TreeSelect that can be applied to a tree.

Details and Options

  • In TreeSelect[tree,crit], tree must be a valid Tree object.
  • TreeSelect[crit][tree] is equivalent to TreeSelect[tree,crit].
  • TreeSelect traverses the descendants of tree in a left-to-right, depth-first order, with children visited before parents.
  • The following options for TreeSelect can be given:
  • "TraversalOrder""PostOrder"what order to visit the descendants
  • Possible values for the option "TraversalOrder" include:
  • "PostOrder"visit each parent after visiting its children, starting from the leaves
    "PreOrder"visit each parent before visiting its children, starting from the root
    "LevelOrder"visit each descendant on a level before visiting descendants on the next level, starting with level 0

Examples

open allclose all

Basic Examples  (2)

Select the subtrees whose root node has an even number as data:

Get the first six leaves of a tree:

Scope  (2)

Select all descendants with three children:

Use the operator form of TreeSelect:

Options  (1)

"TraversalOrder"  (1)

Specify different traversal orders to visit the nodes of a tree:

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

Text

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

BibTeX

@misc{reference.wolfram_2021_treeselect, author="Wolfram Research", title="{TreeSelect}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/TreeSelect.html}", note=[Accessed: 22-June-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_treeselect, organization={Wolfram Research}, title={TreeSelect}, year={2021}, url={https://reference.wolfram.com/language/ref/TreeSelect.html}, note=[Accessed: 22-June-2021 ]}

CMS

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

APA

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