TreeSize

TreeSize[tree]

gives the number of subtrees of tree.

Details

  • The number of subtrees of a Tree object is also the number of its nodes because each node is the root of a subtree of the original tree.
  • TreeSize[tree] is equivalent to TreeCount[tree,_].

Examples

open allclose all

Basic Examples  (1)

Count the subtrees in a tree:

Properties & Relations  (4)

TreeSize[tree] is equivalent to TreeCount[tree,_]:

TreeSize[Tree[{tree1,tree2,}] gives 1+TreeSize[tree1]+TreeSize[tree2]+:

TreeSize[Tree[data,None]] gives 1:

TreeSize[Tree[data,{}]] also gives 1:

TreeLeafCount[Tree[data,{}]] gives 0:

TreeSize can be computed using TreeFold:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2022_treesize, author="Wolfram Research", title="{TreeSize}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/TreeSize.html}", note=[Accessed: 03-December-2022 ]}

BibLaTeX

@online{reference.wolfram_2022_treesize, organization={Wolfram Research}, title={TreeSize}, year={2021}, url={https://reference.wolfram.com/language/ref/TreeSize.html}, note=[Accessed: 03-December-2022 ]}