pub fn is_bigraphical(
degrees1: &[igraph_int_t],
degrees2: &[igraph_int_t],
allowed: impl Into<AllowedEdgeTypes>,
) -> Result<bool>Expand description
Is there a bipartite graph with the given pair of degree sequences?
degrees1 and degrees2 are the degrees of the vertices in the two
partitions. When multi-edges are allowed it suffices that both sequences
have the same sum (and no negative entry); for simple graphs the Gale–Ryser
theorem is used with Berger’s relaxation. Self-loops are meaningless in
bipartite graphs, so only AllowedEdgeTypes::SIMPLE and
AllowedEdgeTypes::MULTI matter (the loops flag is ignored).
Binds igraph_is_bigraphical.
See also Graph::realize_bipartite_degree_sequence, which builds a
realization, and Graph::is_bipartite.
Time complexity: O(n), n being the length of the longer sequence.
§Errors
ErrorKind::InvalidValue if the sum of
the (non-negative) degrees exceeds i64::MAX / 2 (see is_graphical).
§Examples
use igraph::mixing::is_bigraphical;
use igraph::prelude::*;
// K_{2,3}: two vertices of degree 3 and three of degree 2.
assert!(is_bigraphical(&[3, 3], &[2, 2, 2], EdgeTypeSw::Simple)?);
// One vertex cannot have 4 distinct neighbors among 3.
assert!(!is_bigraphical(&[4], &[2, 1, 1], EdgeTypeSw::Simple)?);
assert!(is_bigraphical(&[4], &[2, 1, 1], EdgeTypeSw::Multi)?);
// Realize K_{2,3}'s sequences: the result is the complete bipartite graph.
let g = Graph::realize_bipartite_degree_sequence(
&[3, 3], &[2, 2, 2], EdgeTypeSw::Simple, RealizeDegseq::Smallest)?;
assert_eq!((g.vcount(), g.ecount()), (5, 6));
assert!(g.is_bipartite()?);