Skip to main content

forest_fire_sampling

Function forest_fire_sampling 

Source
pub fn forest_fire_sampling(
    adjacency: &[Vec<usize>],
    n_nodes: usize,
    sample_size: usize,
    forward_prob: f64,
    rng_seed: u64,
) -> Result<Vec<usize>>
Expand description

Forest-fire graph sampling.

Mimics a “fire spreading” process: from each burning node, a geometrically distributed number of unvisited neighbours are “burned” with forward probability forward_prob. The process regenerates from a new random seed when all fires die out.

Forest-fire sampling is known to preserve heavy-tail degree distributions and densification patterns (Leskovec et al. 2005).

§Parameters

  • adjacency – unweighted adjacency list.
  • n_nodes – total number of nodes.
  • sample_size – target number of sampled nodes.
  • forward_prob – probability of spreading to each neighbour (0 < p < 1).
  • rng_seed – PRNG seed.

§Errors

Returns GraphError::InvalidParameter for invalid inputs.