Expand description
Turán graph constructor (ALGO-CN-027).
Counterpart of igraph_turan() in
references/igraph/src/constructors/full.c:281-325.
The Turán graph T(n, r) is the complete r-partite graph on n
vertices whose partition sizes differ by at most one — i.e. the
densest graph on n vertices that does not contain a clique of size
r + 1 (Turán’s theorem, 1941). Concretely:
- Let
q = n / rands = n % r. - The first
spartitions get sizeq + 1; the remainingr − spartitions get sizeq. - The result is
full_multipartite(&[q+1; s] ++ &[q; r-s], false, MultipartiteMode::All).
Turán graphs are always undirected. The result bundles the graph
with a types vector recording the partition index of every vertex
(partition-major order).
Degenerate cases (matching upstream):
n == 0→ empty graph with emptytypes. Therargument is ignored.r > n→ silently capped tor = n, yieldingnsingleton partitions (i.e. the complete graphK_nwithtypes = [0, 1, …, n − 1]).r == 0→IgraphError::InvalidArgument(the partition count must be positive whenn > 0).
Time complexity: O(|V| + |E|), dominated by the wrapped
full_multipartite call.
Functions§
- turan
- Build the Turán graph
T(n, r).