pub fn degree_sequence_game_vl(
degrees: &[u32],
seed: u64,
) -> IgraphResult<Graph>Expand description
Sample a random connected, simple undirected graph that exactly realises the given degree sequence, approximately uniformly, via the Viger–Latapy edge-switch Markov chain.
degrees— undirected degree of every vertex. Length defines vertex countn.seed— drives the internalSplitMix64PRNG.
§Errors
- Vertex count exceeds
u32::MAX. - Edge count
Σd / 2exceedsu32::MAX. - Degree sum overflows
u64. - Degree sequence is not graphical (sum is odd, or fails
Erdős–Gallai), or any single degree exceeds
n - 1. - Sequence is graphical but cannot be realized as a connected
simple graph — e.g. it contains a
0degree on more than one vertex while the rest demand a single component.
§Examples
use rust_igraph::degree_sequence_game_vl;
// 4-cycle: every vertex degree 2 ⇒ 4 edges total, connected.
let g = degree_sequence_game_vl(&[2, 2, 2, 2], 7).unwrap();
assert_eq!(g.vcount(), 4);
assert_eq!(g.ecount(), 4);
assert!(!g.is_directed());