Skip to main content

forest_fire_game

Function forest_fire_game 

Source
pub fn forest_fire_game(
    n: u32,
    fw_prob: f64,
    bw_factor: f64,
    ambs: u32,
    directed: bool,
    seed: u64,
) -> IgraphResult<Graph>
Expand description

Generate a forest-fire-model random graph on n vertices.

  • n — vertex count. n = 0 returns an empty graph; n = 1 returns a single isolated vertex.
  • fw_prob — forward burning probability p ∈ [0, 1). The number of outgoing neighbours a burn picks from each ambassador follows Geom(1 − p).
  • bw_factor — backward burning ratio r ≥ 0. The number of incoming neighbours follows Geom(1 − r·p); the product r · p must also stay in [0, 1).
  • ambs — number of ambassadors each new node connects to. ambs = 0 shortcuts to an edgeless n-vertex graph.
  • directed — whether to return a directed graph. The internal burn tracks in/out-neighbour lists regardless of this flag; only the final Graph honours it.
  • seed — seeds the internal SplitMix64 PRNG.

§Errors

Returns IgraphError::Internal if fw_prob falls outside [0, 1), if bw_factor · fw_prob is outside [0, 1), or if either parameter is non-finite.

§Examples

use rust_igraph::forest_fire_game;

// Light burn: small fw_prob keeps edges close to the ambassador count.
let g = forest_fire_game(100, 0.05, 0.3, 2, true, 0xF00D).unwrap();
assert_eq!(g.vcount(), 100);
assert!(g.is_directed());
// Each non-root vertex cites >= 1 ambassador, so at least n - 1 edges.
assert!(g.ecount() >= 99);