RulesTree

RulesTree[data{rule1,rule2,}]

gives a tree whose root contains data and that has children specified by the rulei.

Details and Options

  • RulesTree gives a Tree object.
  • The children of RulesTree[data{rule1,rule2,}] are given by the list {RulesTree[rule1],RulesTree[rule2],}.
  • The children of RulesTree[data<|key1rule1,key2rule2,|>] are given by the association <|key1RulesTree[rule1],key2RulesTree[rules2],|>.
  • RulesTree[data] for data not of the form {}, <||> or None is equivalent to RulesTree[dataNone]. »
  • RulesTree takes the same options as Tree.

Examples

open allclose all

Basic Examples  (3)

Construct a tree with three leaves:

Construct a tree with several levels:

Construct a tree with named edges:

Scope  (4)

Construct a leaf with no child:

Construct an inner node with no children:

Specify a list of children:

Specify an association of children:

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 styles 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:

Applications  (1)

Construct a tree of the House of Atreus:

Properties & Relations  (2)

RulesTree constructs a tree associated with the given rules:

Use TreeRules on the result to recover the original rules:

RulesTree can be computed with NestTree:

Possible Issues  (1)

RulesTree[exprNone] is generally equivalent to RulesTree[expr]:

However, the None is necessary to specify a tree with data of the form lhs{e1,e2,} or lhsNone:

Without the None, this would be treated as a tree whose root contains lhs with children {RulesTree[e1],RulesTree[e2],}:

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

Text

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

CMS

Wolfram Language. 2021. "RulesTree." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/RulesTree.html.

APA

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_rulestree, organization={Wolfram Research}, title={RulesTree}, year={2022}, url={https://reference.wolfram.com/language/ref/RulesTree.html}, note=[Accessed: 09-December-2024 ]}