Skip to main content

Module full_multipartite

Module full_multipartite 

Source
Expand description

Full multipartite graph constructor (ALGO-CN-026).

Counterpart of igraph_full_multipartite() in references/igraph/src/constructors/full.c:154-247.

A complete (full) multipartite graph on partitions of sizes n_0, n_1, …, n_{k-1} is the graph whose vertex set is the disjoint union of the k partitions, with an edge between every pair of vertices that belong to different partitions and no edge between vertices that share a partition.

Vertices are laid out in partition-major order:

partition 0: vertices [0,                 n_0)
partition 1: vertices [n_0,         n_0 + n_1)
…
partition k: vertices [Σ n_i (i < k), Σ n_i (i ≤ k))

Edge orientation is governed by MultipartiteMode:

  • MultipartiteMode::Out (directed only) — emit (from, to) where from lives in the earlier partition (lower partition index).
  • MultipartiteMode::In (directed only) — emit (to, from), reversing every arc.
  • MultipartiteMode::All — for directed graphs, emit both (from, to) and (to, from) per pair (mutual). For undirected graphs this is the only meaningful setting; Out and In collapse to the same edge multiset, so we accept All as the canonical choice and treat Out/In as equivalent.

Edge counts:

  • Empty partition list (k = 0) — empty graph, no vertices.
  • E_undirected = Σ_{i < j} n_i · n_j, equivalently ½ · Σ_i n_i · (N − n_i) where N = Σ_i n_i.
  • Directed Out/In arc count equals E_undirected.
  • Directed All arc count equals 2 · E_undirected.

The returned FullMultipartite bundles the constructed Graph with a types vector that records the partition index of every vertex (types[v] is the partition v lives in), matching the optional types out-parameter of the upstream C entry point.

Degenerate cases:

  • partitions == &[] → empty graph (vcount = 0, types == []).
  • Any individual n_i == 0 → that partition contributes no vertices and no edges; later partitions are still numbered consecutively in the natural way.
  • partitions == &[n] (single partition) → graph with n isolated vertices, no edges, types == [0; n].

Time complexity: O(|V| + |E|).

Structs§

FullMultipartite
Bundled return type of full_multipartite.

Enums§

MultipartiteMode
Direction policy for full_multipartite.

Functions§

full_multipartite
Build the complete (full) multipartite graph on the given partitions.