pub fn de_bruijn(m: u32, n: u32) -> IgraphResult<Graph>Expand description
Build the De Bruijn graph B(m, n).
The result is always directed, matches the C convention
(IGRAPH_DIRECTED). Self-loops appear naturally whenever the
rewrite (i, ((i * m) mod m^n) + b) lands back on i — most
notably for m == 1, n ≥ 1, where the single vertex 0 has a
self-loop, and along the main diagonal of B(m, 1).
§Errors
IgraphError::InvalidArgument—m.pow(n)would overflowu32(vertex count too large to address with the graph’su32vertex id width). The check usesu32::checked_powso the failure mode is deterministic and never produces a silently-wrapped graph.IgraphError::InvalidArgument— the edge countm^(n+1)overflowsusizeso the edge buffer cannot be sized safely.
§Examples
use rust_igraph::de_bruijn;
// B(2, 2) — 4 vertices, 8 arcs, 4 of which are self-loops or pairs.
let g = de_bruijn(2, 2).unwrap();
assert_eq!(g.vcount(), 4);
assert_eq!(g.ecount(), 8);
assert!(g.is_directed());