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

  • 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.

Examples

open allclose all

Basic Examples  (3)

Generate a random tree with 10 subtrees:

Generate a list of random trees:

Generate an array of random trees:

Properties & Relations  (2)

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

RandomTree generates random trees of a certain size:

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

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

Text

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

BibTeX

@misc{reference.wolfram_2021_randomtree, author="Wolfram Research", title="{RandomTree}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/RandomTree.html}", note=[Accessed: 27-November-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_randomtree, organization={Wolfram Research}, title={RandomTree}, year={2021}, url={https://reference.wolfram.com/language/ref/RandomTree.html}, note=[Accessed: 27-November-2021 ]}

CMS

Wolfram Language. 2021. "RandomTree." Wolfram Language & System Documentation Center. Wolfram Research. 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