Skip to main content

simple_interconnected_islands_game

Function simple_interconnected_islands_game 

Source
pub fn simple_interconnected_islands_game(
    islands_n: u32,
    islands_size: u32,
    islands_pin: f64,
    n_inter: u32,
    seed: u64,
) -> IgraphResult<Graph>
Expand description

Generate a random graph made of islands_n interconnected Erdős–Rényi islands.

  • islands_n — number of islands.
  • islands_size — vertex count per island (all islands have the same size).
  • islands_pin ∈ [0, 1] — within-island edge probability.
  • n_inter — number of bipartite edges drawn between each unordered pair of islands. Must satisfy n_inter ≤ islands_size².
  • seed — seeds the internal SplitMix64 PRNG.

The returned graph is always undirected and simple. Vertex labelling: island is occupies the contiguous range [is · islands_size, (is + 1) · islands_size).

§Errors

Returns IgraphError::InvalidArgument if islands_pin is outside [0, 1], if n_inter > islands_size², or if the total vertex count islands_n · islands_size overflows u32.

§Examples

use rust_igraph::simple_interconnected_islands_game;

// 4 islands of size 25 with p = 0.4 within and 3 cross-island edges
// between each pair → 100 vertices total.
let g = simple_interconnected_islands_game(4, 25, 0.4, 3, 0xA15_1A4D).unwrap();
assert_eq!(g.vcount(), 100);
assert!(!g.is_directed());
// Inter-island contribution alone is C(4, 2) · 3 = 18 edges; the
// intra-island contribution adds many more.
assert!(g.ecount() >= 18);