Skip to main content

full_multipartite

Function full_multipartite 

Source
pub fn full_multipartite(
    partitions: &[u32],
    directed: bool,
    mode: MultipartiteMode,
) -> IgraphResult<FullMultipartite>
Expand description

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

partitions[i] gives the number of vertices in partition i. The empty slice yields an empty graph and an empty types vector.

See the module documentation for the precise semantics of MultipartiteMode and the vertex / edge layout.

§Errors

  • IgraphError::InvalidArgument — the total vertex count Σ partitions[i] overflows u32, or the (intermediate) edge count overflows usize. The overflow checks mirror the upstream IGRAPH_SAFE_ADD / IGRAPH_SAFE_MULT guards.

§Examples

use rust_igraph::{full_multipartite, MultipartiteMode};

// Complete bipartite K_{2,3} on 5 vertices, undirected → 6 edges.
let result = full_multipartite(&[2, 3], false, MultipartiteMode::All).unwrap();
assert_eq!(result.graph.vcount(), 5);
assert_eq!(result.graph.ecount(), 6);
assert_eq!(result.types, vec![0, 0, 1, 1, 1]);

// Same partitions, directed mutual → 12 arcs.
let dir = full_multipartite(&[2, 3], true, MultipartiteMode::All).unwrap();
assert_eq!(dir.graph.ecount(), 12);