Skip to main content

cut_value

Function cut_value 

Source
pub fn cut_value(graph: &Graph, partition: &[bool]) -> IgraphResult<usize>
Expand description

Compute the cut value for a given vertex partition.

Returns the number of edges with exactly one endpoint in each side of the partition. For directed graphs, counts edges crossing in either direction.

§Examples

use rust_igraph::{Graph, cut_value};

let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(0, 3).unwrap();

// Partition {0,1} vs {2,3}: edges 1-2 and 0-3 cross → value = 2
let partition = vec![true, true, false, false];
assert_eq!(cut_value(&g, &partition).unwrap(), 2);