pub fn degree_sequence_game_configuration(
out_degrees: &[u32],
in_degrees: Option<&[u32]>,
seed: u64,
) -> IgraphResult<Graph>Expand description
Sample a random graph realising the given degree sequence(s) via the configuration / stub-matching model.
out_degrees— degree of every vertex (undirected) or out-degree of every vertex (directed). Length defines vertex countn.in_degrees— whenSome(seq), switches to directed mode andseq[i]is the in-degree of vertexi. Must have the same length asout_degreesand the same total.seed— drives the internalSplitMix64PRNG.
The output is a multigraph: self-loops and parallel edges can occur whenever the degree sequence allows them, with the natural configuration-model probabilities.
§Errors
in_degreeslength disagrees without_degreeslength.- Degree sum overflows
u64(only possible at billion-vertex scale). - Undirected mode with an odd
Σ out_degrees(not graphical). - Directed mode with
Σ out_degrees != Σ in_degrees. - Edge count overflows
u32(igraph’s hardECOUNT_MAX). - Vertex count exceeds
u32::MAX.
§Examples
use rust_igraph::degree_sequence_game_configuration;
// Undirected 4-cycle target: every vertex degree 2 ⇒ 4 edges total.
let g = degree_sequence_game_configuration(&[2, 2, 2, 2], None, 7).unwrap();
assert_eq!(g.vcount(), 4);
assert_eq!(g.ecount(), 4);
assert!(!g.is_directed());