aryagraph.generators.random.random_tree#

aryagraph.generators.random.random_tree(n: int, *, directed: bool = False, seed: int | Generator | None = None) → Graph[source]#

Uniformly random labeled tree on n >= 1 nodes (decoded from a random Prüfer sequence).

Every one of the n^(n-2) labeled trees is equally likely. With directed, arcs point away from node 0 (an arborescence rooted at 0). Linear-time decoding.