Skip to main content

Module turan

Module turan 

Source
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 / r and s = n % r.
  • The first s partitions get size q + 1; the remaining r − s partitions get size q.
  • 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 empty types. The r argument is ignored.
  • r > n → silently capped to r = n, yielding n singleton partitions (i.e. the complete graph K_n with types = [0, 1, …, n − 1]).
  • r == 0IgraphError::InvalidArgument (the partition count must be positive when n > 0).

Time complexity: O(|V| + |E|), dominated by the wrapped full_multipartite call.

Functions§

turan
Build the Turán graph T(n, r).