Skip to main content

is_bigraphical

Function is_bigraphical 

Source
pub fn is_bigraphical(
    degrees1: &[u32],
    degrees2: &[u32],
    edge_types: EdgeTypeFilter,
) -> bool
Expand description

Test whether a bi-degree-sequence is bigraphical (realizable as a bipartite graph).

degrees1 and degrees2 are the degree sequences of the two partitions. Self-loops are impossible in bipartite graphs, so the edge_types parameter only distinguishes Simple vs Multi.

§Algorithms

  • Simple: Gale–Ryser theorem (Berger 2014 relaxation), O(n).
  • Multi: sum equality check, O(n).

§Examples

use rust_igraph::{EdgeTypeFilter, is_bigraphical};

// Complete bipartite K_{2,3}: [3,3] and [2,2,2]
assert!(is_bigraphical(&[3, 3], &[2, 2, 2], EdgeTypeFilter::Simple));

// Unequal sums → not bigraphical
assert!(!is_bigraphical(&[3, 3], &[2, 2, 1], EdgeTypeFilter::Multi));