RandomTree
RandomTree[n]
gives a pseudorandom tree with n nodes.
RandomTree[n,k]
gives a list of k pseudorandom trees.
RandomTree[n,{k1,k2,…}]
gives a k1× k2×… array of trees.
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)
Options (9)
Styling Individual Tree Elements (2)
Styling Entire Tree (4)
Tree Layout and Graphics Options (3)
Properties & Relations (6)
RandomTree[n,…] uses integers 1, …, n:
Use TreeMap to replace data in the tree:
RandomTree gives pseudorandom trees:
Use SeedRandom to get repeatable random trees:
Use BlockRandom to block one use of RandomTree from affecting others:
RandomTree[n] can produce n! CatalanNumber[n-1] different trees:
RandomTree[n] samples from the uniform distribution over the labeled, rooted, ordered trees of size n:
RandomTree generates random trees of a certain size:
NestTree can be used to generate random trees with random data and numbers of children:
Text
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.
APA
Wolfram Language. (2021). RandomTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomTree.html