Expand description
Star graph constructor (ALGO-CN-002).
Counterpart of igraph_star() in
references/igraph/src/constructors/regular.c:75-141.
A star graph on n vertices designates one vertex as the centre
(often vertex 0); every other vertex is a leaf connected only to
the centre. The shape of the edge is controlled by a four-way
StarMode:
StarMode::Out— directed, edges flow from the centre to each leaf (center → leaf).StarMode::In— directed, edges flow from each leaf to the centre (leaf → center).StarMode::Mutual— directed, both arcscenter → leafandleaf → centerare emitted for every leaf.StarMode::Undirected— undirected; the underlying graph is directed =falseand a single edge{center, leaf}is added per leaf.
Edge enumeration mirrors the upstream C loop exactly: leaves are
visited in vertex-id order [0, center) ∪ (center, n) and the arc
direction is determined by the mode. For Mutual the forward arc
center → leaf is always emitted before the back-arc leaf → center
for that leaf.
Edge counts:
n = 0orn = 1— no edges.n ≥ 2, mode ∈ {Out, In, Undirected} —n - 1edges.n ≥ 2, mode = Mutual —2(n - 1)edges.
Time complexity: O(|V|).
Enums§
- Star
Mode - Direction policy for
star_graph.
Functions§
- star_
graph - Build a star graph on
nvertices with the givencenterand arc policymode.