pub fn hamming(n: u32, q: u32, directed: bool) -> IgraphResult<Graph>Expand description
Build the d-dimensional Hamming graph H(n, q).
Returns a graph with q^n vertices where two vertices share an
edge iff their base-q digit representations differ in exactly one
position. For the directed variant every edge points from the
lower-indexed endpoint to the higher-indexed one (the canonical
orientation used by upstream igraph).
§Edge cases
n = 0returns the singleton (one vertex, zero edges), regardless ofq.n > 0andq = 0returns the null graph (zero vertices, zero edges).q = 1returns the singleton.q = 2producesQ_n, equivalent tocrate::hypercube.
§Errors
IgraphError::InvalidArgument—q^noverflowsu32, or the edge count overflowsusize.
§Examples
use rust_igraph::hamming;
// H(2, 3) — 9 vertices, 18 edges, 4-regular.
let g = hamming(2, 3, false).unwrap();
assert_eq!(g.vcount(), 9);
assert_eq!(g.ecount(), 18);