Expand description
Extended chordal ring constructor (ALGO-CN-028).
Counterpart of igraph_extended_chordal_ring() in
references/igraph/src/constructors/regular.c:868-963.
An extended chordal ring is the cycle C_n together with one
additional chord per row of a chord matrix W. The matrix is
interpreted in upstream igraph as follows:
period = ncol(W). The period must dividenodes.- For every vertex
i ∈ [0, nodes)and every rowj ∈ [0, nrow(W))the constructor emits the directed edge(i, (i + W[j][i mod period]) mod nodes). Matrix entries are allowed to be negative — the result is reduced into[0, nodes)with Euclidean modulus.
The total edge count is therefore nodes + nodes * nrow(W) (plus an
extra factor of 2 only inside the candidate buffer — igraph_create
still treats each (i, v) as a single directed/undirected edge). The
result is not simplified: matrix patterns that produce the same
chord twice (e.g. the article example with W = [[4, 2], [8, 10]] on
12 nodes) intentionally retain the parallel edges so the caller can
preserve the published multigraph or simplify it themselves.
Rust matrix encoding: w is passed as &[&[i64]] — a slice of rows
where every row has the same length (the period). An empty w (no
rows) skips the chord pass entirely and returns the bare cycle
C_n; the upstream divide-by-zero in that case is replaced with a
defensive no-op.
Degenerate / error cases (matching upstream wherever it is defined):
nodes < 3→IgraphError::InvalidArgument.nrow(W) > 0and any row has a different length than the first →IgraphError::InvalidArgument(the C version stores the matrix as a true rectangle and cannot represent ragged input — we reject it explicitly).nrow(W) > 0andperiod == 0→IgraphError::InvalidArgument(a zero-column matrix is not a valid chord spec).nrow(W) > 0andnodes % period != 0→IgraphError::InvalidArgument.
Time complexity: O(|V| + |E|) = O(nodes · (1 + nrow)).
Functions§
- extended_
chordal_ ring - Build the extended chordal ring
R(nodes, W).