Expand description
Wheel graph constructor (ALGO-CN-003).
Counterpart of igraph_wheel() in
references/igraph/src/constructors/regular.c:145-287.
A wheel graph on n vertices is the union of a star and a cycle:
one vertex (the centre) is connected to every other vertex via
star-spokes, and those n - 1 rim vertices are linked by a cycle.
Wheel layout is controlled by WheelMode, whose four cases line
up with crate::StarMode:
WheelMode::Out— directed, every spoke flows from the centre to a leaf, every rim edge isprev → next(visited in the[0, center) ∪ (center, n)raw vertex order).WheelMode::In— directed, every spoke flows from each leaf to the centre, rim directionprev → nextmatchesOut.WheelMode::Mutual— directed, every spoke and every rim edge is emitted in both directions. Star-spokes are added first (forward arc before back-arc, per leaf); the rim is then appended ase_0, e_1, …, e_{n-2}, rev(e_{n-2}), rev(e_{n-3}), …, rev(e_0)— i.e. forward rim sweep followed by the reverse of each forward arc in reverse-discovery order, matching the upstream C loop verbatim.WheelMode::Undirected— undirected; each spoke and each rim edge is added once,Graph::add_edgescanonicalises endpoints to(min, max).
Edge counts:
n = 0orn = 1— wheel ≡ star; no edges.n ≥ 2, mode ∈ {Out, In, Undirected} —2(n − 1)edges (n − 1spokes plusn − 1rim edges).n ≥ 2, mode = Mutual —4(n − 1)edges.
Degenerate two- and three-vertex wheels are intentionally non-simple
(upstream igraph_wheel documents this): the two-vertex wheel
contains a self-loop on the only rim vertex (the rim collapses to a
1-cycle), and the three-vertex wheel produces parallel edges between
the two rim vertices (rim collapses to a 2-cycle).
Time complexity: O(|V|).
Enums§
- Wheel
Mode - Direction policy for
wheel_graph.
Functions§
- wheel_
graph - Build a wheel graph on
nvertices with the givencenterand arc policymode.