hrg_generate#
- graph_tool.inference.hrg_generate(tree, p)[git][source]#
Sample a graph from a hierarchical random graph.
- Parameters:
- tree
Graph Binary dendrogram as returned by
hrg_fit().- p
VertexPropertyMap Connection probability of every internal vertex.
- tree
- Returns:
- g
Graph Undirected graph whose vertices are the leaves of the tree.
- g
See also
hrg_fitFit of a hierarchical random graph
graph_tool.generation.generate_sbmGraphs 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