pub fn bipartite_game_gnp(
n1: u32,
n2: u32,
p: f64,
directed: bool,
mode: BipartiteMode,
seed: u64,
) -> IgraphResult<BipartiteGraph>Expand description
Generate a random bipartite graph from the G(n1, n2, p) model.
Every possible cross-partition edge is included independently with
probability p. The expected number of edges is
p · max_edges(n1, n2, directed, mode).
n1— bottom partition size (vertices0..n1).n2— top partition size (verticesn1..n1+n2).p ∈ [0, 1]— edge probability.directed— generate a directed bipartite graph; whenfalseedges are undirected andmodeis effectivelyAll(pair spacen1·n2, no mutual pairs because the graph is undirected).mode— seeBipartiteMode. Ignored whendirected == false.seed— initialises an internalSplitMix64PRNG. The same(n1, n2, p, directed, mode, seed)always yields the same graph.
§Errors
Returns IgraphError::InvalidArgument if p is NaN, infinite, or
outside [0, 1], or if n1 + n2 overflows u32.
§Examples
use rust_igraph::{bipartite_game_gnp, BipartiteMode};
// Expected edges ≈ 0.3 · 5 · 8 = 12.
let bg = bipartite_game_gnp(5, 8, 0.3, false, BipartiteMode::All, 42).unwrap();
assert_eq!(bg.graph.vcount(), 13);
assert_eq!(bg.types.len(), 13);
// Every edge crosses the partition.
for eid in 0..bg.graph.ecount() {
let (u, v) = bg.graph.edge(eid as u32).unwrap();
assert_ne!(bg.types[u as usize], bg.types[v as usize]);
}