Expand description
Ring / path / cycle constructors (ALGO-CN-001).
Counterpart of igraph_ring(), igraph_path_graph() and
igraph_cycle_graph() in
references/igraph/src/constructors/regular.c:495-604.
The model lays n vertices in a sequence 0, 1, …, n-1 and joins
consecutive vertices in order. Three boolean flags shape the result:
directed— emit a digraph. Edges always run in the forward direction(i, i+1). Ignored only by the parity ofmutual.mutual— only applied whendirectedistrue; emits the back-arc(i+1, i)alongside every forward arc. Undirected construction ignoresmutualentirely (matching upstream).circular— close the sequence with the wrap-around edge(n-1, 0). Withcircular = falsethe result is the pathP_n; withcircular = trueit is the cycleC_n.
Edge count is n - 1 for a path and n for a cycle, doubled when
directed && mutual. The two convenience wrappers
path_graph (alias for circular = false) and
cycle_graph (alias for circular = true) mirror the upstream
one-line wrappers exactly.
Degenerate cases mirror upstream behaviour verbatim:
n == 0— the empty graph.n == 1,circular == false— a single isolated vertex.n == 1,circular == true— a self-loop(0, 0). Not simple.n == 2,circular == true,directed == false— two parallel edges between0and1. Not simple.
Time complexity: O(|V|).
Functions§
- cycle_
graph - Cycle graph
C_n: convenience wrapper forring_graph(n, directed, mutual, true). - path_
graph - Path graph
P_n: convenience wrapper forring_graph(n, directed, mutual, false). - ring_
graph - Lay
nvertices in a sequence and join them; close the loop iffcircular.