Skip to main content

static_power_law_game

Function static_power_law_game 

Source
pub fn static_power_law_game(
    no_of_nodes: u32,
    no_of_edges: u32,
    exponent_out: f64,
    exponent_in: Option<f64>,
    loops: bool,
    multiple: bool,
    finite_size_correction: bool,
    seed: u64,
) -> IgraphResult<Graph>
Expand description

Sample a random graph whose degree distribution follows a power law of prescribed exponent(s) (Goh et al. 2001).

Builds the fitness vector fitness[i] = j^α with j = n, n-1, …, 1 and α = -1 / (exponent - 1), optionally with the Cho et al. (2009) finite-size correction shifting j upward, then delegates to static_fitness_game.

  • no_of_nodes — vertex count n.
  • no_of_edges — exact number of edges to generate.
  • exponent_out — power-law exponent for the (out-)degree distribution. Must be >= 2. Pass f64::INFINITY to recover an Erdős–Rényi sampler.
  • exponent_inSome(e) selects a directed graph with an independent in-degree exponent (also >= 2); the in-fitness vector is randomly shuffled before sampling to decorrelate the in- and out-degree sequences. None selects an undirected graph.
  • loops, multiple — passed through to static_fitness_game.
  • finite_size_correction — when true, apply the Cho et al. shift on each exponent that satisfies α < -0.5 (equivalently exponent < 3).
  • seed — initialises an internal SplitMix64 PRNG so the output is reproducible given the inputs.

§Errors

Returns IgraphError::InvalidArgument if:

  • exponent_out < 2 or exponent_in = Some(e) with e < 2;
  • exponent_out is NaN, or exponent_in = Some(e) with NaN;
  • any condition listed under static_fitness_game fires when forwarding the synthesised fitness vectors.

§Examples

use rust_igraph::static_power_law_game;

let g = static_power_law_game(50, 100, 2.5, None, false, true, true, 7).unwrap();
assert_eq!(g.vcount(), 50);
assert_eq!(g.ecount(), 100);
assert!(!g.is_directed());