TreeDepth
TreeDepth[tree]
gives the maximum level of tree.
TreeDepth[tree,pattern]
gives the maximum level of the subtree with data matching pattern.
Examples
open allclose allProperties & Relations (6)
TreeDepth[tree] is generally equivalent to TreeDepth[tree,_]:
In TreeDepth[tree], empty lists of children contribute one level:
TreeDepth[Tree[{tree1,tree2,…}]] gives 1+Max[TreeDepth[tree1],TreeDepth[tree2],…]:
TreeDepth[Tree[data,None]] gives 0:
TreeDepth[Tree[data,{}]] gives 1:
TreeDepth can be computed using TreeFold:
Depth[expr] is equivalent to 1+TreeDepth[ExpressionTree[expr,"Subexpressions"]]:
Depth[expr,HeadsTrue] is equivalent to 1+TreeDepth[ExpressionTree[expr,"Subexpressions",HeadsTrue]]:
Text
Wolfram Research (2021), TreeDepth, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeDepth.html (updated 2022).
CMS
Wolfram Language. 2021. "TreeDepth." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/TreeDepth.html.
APA
Wolfram Language. (2021). TreeDepth. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeDepth.html