Skip to main content

iea_game

Function iea_game 

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

Generate a random multigraph through independent edge allocation.

  • n — number of vertices.
  • m — number of edges to draw. The result graph has exactly m edges (including any multi-edges or self-loops that occur).
  • directed — generate a directed graph. When false, the sampled ordered pair is stored as an undirected edge.
  • loops — when true, the sampler may place self-loop edges (u, u). When false, the diagonal of the pair space is excluded and every edge connects two distinct vertices.
  • seed — initialises an internal SplitMix64 PRNG. Same (n, m, directed, loops, seed) always yields the same graph.

§Errors

Returns IgraphError::InvalidArgument when:

  • m exceeds the internal u32::MAX edge cap.
  • m > 0 and n == 0 (no vertices to place edges on).
  • m > 0, loops == false, and n < 2 (no non-self pairs exist).

§Examples

use rust_igraph::iea_game;

// Directed multigraph: 100 vertices, 500 edges, self-loops allowed.
let g = iea_game(100, 500, true, true, 0xDEAD_BEEF).unwrap();
assert_eq!(g.vcount(), 100);
assert_eq!(g.ecount(), 500);
assert!(g.is_directed());