WLJS LogoWLJS Notebook

TreeCount

TreeCount[tree, pattern] gives the number of subtrees of tree whose data matches pattern.

  • TreeCount[tree, pattern, levelspec] gives the total number of subtrees with data matching pattern that appear at the levels in tree specified by levelspec.
  • TreeCount[pattern] represents an operator form of TreeCount that can be applied to a tree.

Examples

tree = Tree[a, {Tree[b, {c, d}], Tree[b, {e}]}];
TreeCount[tree, b]

Please visit the official Wolfram Language Reference for more details.

On this page