pub fn watts_strogatz_game(
size: u32,
nei: u32,
p: f64,
loops: bool,
multiple: bool,
seed: u64,
) -> IgraphResult<Graph>Expand description
Generate a 1-D Watts–Strogatz small-world graph.
Builds a periodic ring lattice of size vertices where every
vertex connects to its nei nearest neighbours on each side
(total degree 2·nei), then independently rewires each endpoint
of each edge with probability p. The candidate replacement is
uniformly sampled from the vertex set, optionally subject to a
no-self-loop / no-multi-edge rejection rule.
loops = false rejects any candidate equal to the kept endpoint,
multiple = false additionally rejects candidates that would
duplicate an existing edge. Both default to false in the canonical
Watts–Strogatz Nature ’98 model and in python-igraph’s
Graph.Watts_Strogatz. The output is always undirected.
§Errors
Returns IgraphError::InvalidArgument if:
size == 0, or2·nei + 1 > size(the ring would self-overlap), orpis NaN, infinite, or outside[0, 1].
§Examples
use rust_igraph::watts_strogatz_game;
let g = watts_strogatz_game(10, 2, 0.0, false, false, 42).unwrap();
assert_eq!(g.vcount(), 10);
// p = 0 leaves the lattice untouched: 10 vertices × 2 neighbours
// per side / 2 (undirected) × 2 sides = 20 edges.
assert_eq!(g.ecount(), 20);