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 countn.no_of_edges— exact number of edges to generate.exponent_out— power-law exponent for the (out-)degree distribution. Must be>= 2. Passf64::INFINITYto recover an Erdős–Rényi sampler.exponent_in—Some(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.Noneselects an undirected graph.loops,multiple— passed through tostatic_fitness_game.finite_size_correction— whentrue, apply the Cho et al. shift on each exponent that satisfiesα < -0.5(equivalentlyexponent < 3).seed— initialises an internalSplitMix64PRNG so the output is reproducible given the inputs.
§Errors
Returns IgraphError::InvalidArgument if:
exponent_out < 2orexponent_in = Some(e)withe < 2;exponent_outis NaN, orexponent_in = Some(e)with NaN;- any condition listed under
static_fitness_gamefires 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());