- random_unlabeled_tree(n, *, number_of_trees=None, seed=None)#
Returns a tree or list of trees chosen randomly.
Returns one or more (depending on
number_of_trees) unlabeled trees with
nnodes drawn uniformly at random.
The number of nodes
- number_of_treesint or None (default)
If not None, this number of trees is generated and returned.
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
nis zero (because the null graph is not a tree).
This function generates an unlabeled tree uniformly at random using Wilf’s algorithm “Free” of . The algorithm needs to compute some counting functions that are relatively expensive: in case several trees are needed, it is advisable to use the
number_of_treesoptional argument to reuse the counting functions.