WOLFRAM

Copy to clipboard.
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)Summary of the most common use cases

Construct a tree with three leaves:

Out[1]=1

Construct a tree with several levels:

Out[1]=1

Construct a tree with named edges:

Out[1]=1

Scope  (4)Survey of the scope of standard use cases

Construct a leaf with no child:

Out[1]=1

Construct an inner node with no children:

Out[1]=1
Out[2]=2

Specify a list of children:

Out[1]=1

Specify an association of children:

Out[1]=1

Options  (9)Common values & functionality for each option

Styling Individual Tree Elements  (2)

Specify the label for the generated tree element:

Out[1]=1

Specify labels and styles for subtrees by position:

Out[1]=1

Styling Entire Tree  (4)

Specify labels and styles for all subtrees:

Out[1]=1

Specify the base style:

Out[1]=1

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

Out[1]=1

Specify the base style and styles for individual tree elements:

Out[1]=1

Tree Layout and Graphics Options  (3)

Specify the orientation for the root:

Out[1]=1

Specify a named embedding:

Out[1]=1

Specify Graphics options:

Out[1]=1

Applications  (1)Sample problems that can be solved with this function

Construct a tree of the House of Atreus:

Out[1]=1

Properties & Relations  (2)Properties of the function, and connections to other functions

RulesTree constructs a tree associated with the given rules:

Out[1]=1

Use TreeRules on the result to recover the original rules:

Out[2]=2

RulesTree can be computed with NestTree:

Out[3]=3
Out[4]=4

Possible Issues  (1)Common pitfalls and unexpected behavior

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

Out[1]=1
Out[2]=2

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

Out[3]=3

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

Out[4]=4
Wolfram Research (2021), RulesTree, Wolfram Language function, https://reference.wolfram.com/language/ref/RulesTree.html (updated 2022).
Copy to clipboard.
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).

Copy to clipboard.
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.

Copy to clipboard.
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

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

BibTeX

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

Copy to clipboard.
@misc{reference.wolfram_2025_rulestree, author="Wolfram Research", title="{RulesTree}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/RulesTree.html}", note=[Accessed: 26-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_rulestree, organization={Wolfram Research}, title={RulesTree}, year={2022}, url={https://reference.wolfram.com/language/ref/RulesTree.html}, note=[Accessed: 26-March-2025 ]}

Copy to clipboard.
@online{reference.wolfram_2025_rulestree, organization={Wolfram Research}, title={RulesTree}, year={2022}, url={https://reference.wolfram.com/language/ref/RulesTree.html}, note=[Accessed: 26-March-2025 ]}