hrg_generate

Contents

hrg_generate#

graph_tool.inference.hrg_generate(tree, p)[git][source]#

Sample a graph from a hierarchical random graph.

Parameters:
treeGraph

Binary dendrogram as returned by hrg_fit().

pVertexPropertyMap

Connection probability of every internal vertex.

Returns:
gGraph

Undirected graph whose vertices are the leaves of the tree.

See also

hrg_fit

Fit of a hierarchical random graph

graph_tool.generation.generate_sbm

Graphs from the stochastic block model

Notes

Every pair of leaves is connected independently with the probability of their lowest common ancestor [clauset-hierarchical-2008]. The pairs of each internal vertex are sampled with geometric skips, in time \(O(V + E)\) plus the time to list the leaves of every subtree, \(O(V\log V)\) for balanced trees and \(O(V^2)\) in the worst case.

References

[clauset-hierarchical-2008]

Aaron Clauset, Cristopher Moore and M. E. J. Newman, “Hierarchical structure and the prediction of missing links in networks”, Nature 453, 98-101 (2008), DOI: 10.1038/nature06830 [sci-hub, @tor], arXiv: 0811.0484

Examples

>>> g = gt.collection.data["karate"]
>>> tree, p, L = gt.hrg_fit(g, niter=500)
>>> h = gt.hrg_generate(tree, p)
>>> print(h.num_vertices())
34