Skip to main content

is_graphical

Function is_graphical 

Source
pub fn is_graphical(
    out_degrees: &[u32],
    in_degrees: Option<&[u32]>,
    edge_types: EdgeTypeFilter,
) -> bool
Expand description

Test whether a degree sequence is graphical (realizable as some graph).

For undirected graphs, pass in_degrees = None. For directed graphs, pass out_degrees and Some(in_degrees).

§Algorithms

  • Simple undirected: Erdős–Gallai theorem (Cloteaux 2015 linear-time).
  • Loopy-simple undirected: Cairns–Mendan modification of Erdős–Gallai.
  • Loopless multi undirected: even sum + sum ≥ 2·max.
  • Loopy multi undirected: even sum only.
  • Simple directed: Fulkerson–Chen–Anstee theorem (Berger 2014 relaxation).
  • Loopy-simple directed: reduces to bigraphical simple (Gale–Ryser).
  • Loopless multi directed: sum_in == sum_out + sum_out >= max_total.
  • Loopy multi directed: sum_in == sum_out only.

§Examples

use rust_igraph::{EdgeTypeFilter, is_graphical};

// Star K_{1,4}: center has degree 4, leaves have degree 1
assert!(is_graphical(&[4, 1, 1, 1, 1], None, EdgeTypeFilter::Simple));

// Odd sum → not graphical
assert!(!is_graphical(&[3, 1, 1], None, EdgeTypeFilter::Simple));