sample_tree {igraph}R Documentation

Sample trees randomly and uniformly

Description

sample_tree() generates a random with a given number of nodes uniform at random from the set of labelled trees.

Usage

sample_tree(n, directed = FALSE, method = c("lerw", "prufer"))

Arguments

n

The number of nodes in the tree

directed

Whether to create a directed tree. The edges of the tree are oriented away from the root.

method

The algorithm to use to generate the tree. ‘prufer’ samples Prüfer sequences uniformly and then converts the sampled sequence to a tree. ‘lerw’ performs a loop-erased random walk on the complete graph to uniformly sampleits spanning trees. (This is also known as Wilson's algorithm). The default is ‘lerw’. Note that the method based on Prüfer sequences does not support directed trees at the moment.

Details

In other words, the function generates each possible labelled tree with the given number of nodes with the same probability.

Value

A graph object.

See Also

Random graph models (games) erdos.renyi.game(), sample_(), sample_bipartite(), sample_correlated_gnp(), sample_correlated_gnp_pair(), sample_degseq(), sample_dot_product(), sample_fitness(), sample_fitness_pl(), sample_forestfire(), sample_gnm(), sample_gnp(), sample_grg(), sample_growing(), sample_hierarchical_sbm(), sample_islands(), sample_k_regular(), sample_last_cit(), sample_pa(), sample_pa_age(), sample_pref(), sample_sbm(), sample_smallworld(), sample_traits_callaway()

Examples


g <- sample_tree(100, method = "lerw")


[Package igraph version 2.0.3 Index]