RandomTree
✖
RandomTree
Details and Options

- RandomTree[n] samples from the discrete uniform distribution over the
labeled, rooted, ordered trees of size n, where
is given by CatalanNumber[n-1]. Any reordering of the data or subtrees represents a different tree. »
- RandomTree gives a different sequence of pseudorandom trees whenever you run the Wolfram Language. By using SeedRandom, you can get a repeatable sequence. »
- The data of the trees produced by RandomTree[n,…] is taken to be integers 1, …, n. »
- RandomTree takes the same options as Tree.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Options (9)Common values & functionality for each option
Styling Individual Tree Elements (2)
Styling Entire Tree (4)
Specify labels and styles for all subtrees:

https://wolfram.com/xid/0rs5vuxu0-corr7


https://wolfram.com/xid/0rs5vuxu0-xdirf9

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

https://wolfram.com/xid/0rs5vuxu0-s5hou5

Specify the base style and styles for individual tree elements:

https://wolfram.com/xid/0rs5vuxu0-ifl4r4

Tree Layout and Graphics Options (3)
Specify the orientation for the root:

https://wolfram.com/xid/0rs5vuxu0-dis7x2


https://wolfram.com/xid/0rs5vuxu0-i8q32r

Specify Graphics options:

https://wolfram.com/xid/0rs5vuxu0-dbhiu5

Applications (1)Sample problems that can be solved with this function
Properties & Relations (6)Properties of the function, and connections to other functions
RandomTree[n,…] uses integers 1, …, n:

https://wolfram.com/xid/0rs5vuxu0-e1woyd

Use TreeMap to replace data in the tree:

https://wolfram.com/xid/0rs5vuxu0-r66bh4

RandomTree gives pseudorandom trees:

https://wolfram.com/xid/0rs5vuxu0-fxoyn5

Use SeedRandom to get repeatable random trees:

https://wolfram.com/xid/0rs5vuxu0-nqllh0

Use BlockRandom to block one use of RandomTree from affecting others:

https://wolfram.com/xid/0rs5vuxu0-m17cnq

RandomTree[n] can produce n! CatalanNumber[n-1] different trees:

https://wolfram.com/xid/0rs5vuxu0-ww2sv8


https://wolfram.com/xid/0rs5vuxu0-x4ssl1


https://wolfram.com/xid/0rs5vuxu0-8ihep2


https://wolfram.com/xid/0rs5vuxu0-n5uqwz


https://wolfram.com/xid/0rs5vuxu0-iju3el

RandomTree[n] samples from the uniform distribution over the labeled, rooted, ordered trees of size n:

https://wolfram.com/xid/0rs5vuxu0-qvyqco

RandomTree generates random trees of a certain size:

https://wolfram.com/xid/0rs5vuxu0-psblbd

https://wolfram.com/xid/0rs5vuxu0-1xgco2

NestTree can be used to generate random trees with random data and numbers of children:

https://wolfram.com/xid/0rs5vuxu0-50e7sk

https://wolfram.com/xid/0rs5vuxu0-qy3do1

Wolfram Research (2021), RandomTree, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomTree.html (updated 2021).
Text
Wolfram Research (2021), RandomTree, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomTree.html (updated 2021).
Wolfram Research (2021), RandomTree, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomTree.html (updated 2021).
CMS
Wolfram Language. 2021. "RandomTree." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/RandomTree.html.
Wolfram Language. 2021. "RandomTree." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/RandomTree.html.
APA
Wolfram Language. (2021). RandomTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomTree.html
Wolfram Language. (2021). RandomTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomTree.html
BibTeX
@misc{reference.wolfram_2025_randomtree, author="Wolfram Research", title="{RandomTree}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/RandomTree.html}", note=[Accessed: 28-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_randomtree, organization={Wolfram Research}, title={RandomTree}, year={2021}, url={https://reference.wolfram.com/language/ref/RandomTree.html}, note=[Accessed: 28-April-2025
]}