Skip to main content

growing_random_game

Function growing_random_game 

Source
pub fn growing_random_game(
    n: u32,
    m: u32,
    directed: bool,
    citation: bool,
    seed: u64,
) -> IgraphResult<Graph>
Expand description

Generate a growing random graph on n vertices, adding m new edges per step.

  • n — vertex count. n = 0 returns an empty graph; n = 1 returns a single isolated vertex.
  • m — number of new edges contributed per added vertex. m = 0 yields n isolated vertices.
  • directed — generate a directed graph.
  • citation — if true, every new edge originates at the freshly-added vertex; if false, both endpoints are uniformly sampled within the current frontier.
  • seed — initialises an internal SplitMix64 PRNG. Same (n, m, directed, citation, seed) always yields the same graph.

§Errors

Returns IgraphError::Internal if (n - 1) · m overflows u64 (only possible at (u32::MAX, u32::MAX) scale).

§Examples

use rust_igraph::growing_random_game;

// 50-vertex directed citation graph with 2 new edges per step.
// Exactly (n - 1) · m = 49 · 2 = 98 edges.
let g = growing_random_game(50, 2, true, true, 0xCAFE).unwrap();
assert_eq!(g.vcount(), 50);
assert_eq!(g.ecount(), 98);
assert!(g.is_directed());