RootTree

RootTree[tree]

returns the root node of tree as a Tree object.

RootTree[tree,n]

returns a Tree object containing the nodes of tree down to level n.

Details and Options

  • RootTree[Tree[data,{subtree1,subtree2,}] returns Tree[data,{}].
  • RootTree[Tree[data,None]] gives Tree[data,None].
  • RootTree[tree,n] removes all subtrees on levels below level n.
  • In RootTree[tree,n], the level n can be any machine integer or Infinity.
  • A positive level n+1 consists of all subtrees of tree that are children of subtrees on level n.
  • Level 0 corresponds to the root of the tree.
  • Level -1 corresponds to the leaves.
  • A negative level -(n+1) consists of all subtrees whose children are on levels -1, -2, , -n, with highest level -n.

Examples

open allclose all

Basic Examples  (3)

Extract the root of a tree:

Remove all subtrees below level 1:

Remove the leaves, keeping nodes down to level -2:

Options  (9)

Styling Individual Tree Elements  (2)

Specify the label for the generated tree element:

Specify labels and styles for subtrees by position:

Styling Entire Tree  (4)

Specify labels and styles for all subtrees:

Specify the base style:

Specify the style for both the edges and the edges of the tree elements:

Specify the base style and styles for individual tree elements:

Tree Layout and Graphics Options  (3)

Specify the orientation for the root:

Specify a named embedding:

Specify Graphics options:

Properties & Relations  (4)

RootTree[tree] gives Tree[TreeData[tree],None] when TreeChildren[tree] gives None:

RootTree[tree] gives Tree[TreeData[tree],{}] when TreeChildren[tree] gives a list:

RootTree[tree] gives Tree[TreeData[tree],<||>] when TreeChildren[tree] gives an association:

RootTree[tree,-1] gives the whole tree:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2023_roottree, author="Wolfram Research", title="{RootTree}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/RootTree.html}", note=[Accessed: 19-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_roottree, organization={Wolfram Research}, title={RootTree}, year={2022}, url={https://reference.wolfram.com/language/ref/RootTree.html}, note=[Accessed: 19-April-2024 ]}