Skip to main content

bipartite_game_gnm

Function bipartite_game_gnm 

Source
pub fn bipartite_game_gnm(
    n1: u32,
    n2: u32,
    m: u64,
    directed: bool,
    mode: BipartiteMode,
    seed: u64,
) -> IgraphResult<BipartiteGraph>
Expand description

Generate a random bipartite graph from the G(n1, n2, m) model.

Exactly m cross-partition edges are drawn uniformly at random from the max_edges(n1, n2, directed, mode) possible ones. Sampling is without replacement (simple bipartite graph).

§Errors

Returns IgraphError::InvalidArgument if m exceeds the max_edges(n1, n2, directed, mode) capacity, or if n1 + n2 overflows u32.

§Examples

use rust_igraph::{bipartite_game_gnm, BipartiteMode};
let bg = bipartite_game_gnm(4, 6, 10, false, BipartiteMode::All, 7).unwrap();
assert_eq!(bg.graph.vcount(), 10);
assert_eq!(bg.graph.ecount(), 10);
// 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]);
}