generate_forest_fire#
- graph_tool.generation.generate_forest_fire(N, p, r=0.0, ambassadors=1, directed=True)[git][source]#
Generate a graph with the forest fire model.
- Parameters:
- N
int Number of vertices.
- p
float Forward burning probability, in \([0, 1)\).
- r
float(optional, default:0.) Ratio of the backward to the forward burning probability.
- ambassadors
int(optional, default:1) Number of ambassadors of every new vertex.
- directed
bool(optional, default:True) If
True, a directed graph is generated.
- N
- Returns:
- g
Graph The generated graph.
- g
See also
price_networkPreferential attachment
generate_gncGrowing network with copying
Notes
In the forest fire model of Leskovec, Kleinberg, and Faloutsos [leskovec-graph-2007], the vertices arrive one at a time, and every new vertex \(v\) chooses
ambassadorsexisting vertices uniformly at random (all distinct, or all existing vertices if there are fewer) and “burns” them. From every burned vertex \(w\), in the order in which they are burned, a number \(x\) of out-neighbors and a number \(y\) of in-neighbors are sampled from the geometric distributions\[P(x) = (1-p)p^x, \qquad P(y) = (1-rp)(rp)^y,\]with means \(p/(1-p)\) and \(rp/(1-rp)\), and \(\min(x, n_\text{out})\) out-neighbors and \(\min(y, n_\text{in})\) in-neighbors of \(w\) are chosen uniformly at random among the \(n_\text{out}\) and \(n_\text{in}\) ones not burned yet, and burned in turn. The new vertex then links to all the burned vertices, i.e. a directed edge \((v, w)\) is added for each of them. For undirected graphs, the same process is run and the directions of the edges are discarded, so that the forward probability applies to the neighbors that were already present when \(w\) arrived, and the backward probability to the others. This variant reproduces densification and shrinking diameters for suitable parameters. The algorithm runs in time \(O(N + E\log E)\).
References
[leskovec-graph-2007]Jure Leskovec, Jon Kleinberg and Christos Faloutsos, “Graph evolution: Densification and shrinking diameters”, ACM Transactions on Knowledge Discovery from Data 1, 2 (2007), DOI: 10.1145/1217299.1217301 [sci-hub, @tor], arXiv: physics/0603229
Examples
>>> g = gt.generate_forest_fire(10000, 0.37, 0.32 / 0.37) >>> print(g.num_edges()) 87640
A smaller instance is drawn as follows:
>>> g = gt.generate_forest_fire(100, 0.37, 0.32 / 0.37) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... output="generate_forest_fire-small.pdf") <...>
Forest fire graph with \(N=100\), \(p=0.37\), and \(r=0.32/0.37\). The edges point from the newer to the older vertices.#