pub fn grg_game(
n: u32,
radius: f64,
torus: bool,
seed: u64,
) -> IgraphResult<Graph>Expand description
Generate a geometric random graph on n uniformly placed points in
the unit square, connecting pairs strictly closer than radius in
Euclidean distance.
n— vertex count.n = 0returns an empty undirected graph;n = 1returns a single isolated vertex.radius— Euclidean cut-off in the same units as the unit square. Negative values are coerced to0(matching upstream). The maximum meaningful value issqrt(2)for the open square orsqrt(0.5)for the torus (above this every pair is in range).torus— periodic boundary conditions whentrue. The unit square is identified with a torus and y-distances wrap by1 - |Δy|if shorter; x-wrapping is folded into the sweep tail.seed— seeds the internalSplitMix64PRNG. Same(n, radius, torus, seed)always yields the same graph.
The generated graph is always undirected and free of self-loops
(the sweep starts at j = i + 1). It is also simple — each pair
(i, j) is inspected at most once, so no multi-edges arise.
§Errors
Returns IgraphError::Internal if radius is NaN or
infinite.
§Examples
use rust_igraph::grg_game;
// Dense regime: radius near sqrt(2) connects almost every pair.
let dense = grg_game(20, 1.5, false, 0xA110).unwrap();
assert_eq!(dense.vcount(), 20);
assert!(dense.ecount() > 100);
assert!(!dense.is_directed());