pub fn cut_size(
graph: &Graph,
membership: &[u32],
weights: Option<&[f64]>,
) -> IgraphResult<f64>Expand description
Compute the cut size of a partition.
Counts the number of edges (or sum of edge weights) that cross between different clusters.
§Parameters
graph— The input graph.membership— Cluster assignment for each vertex (membership[v]is the cluster id of vertexv). Length must equalvcount.weights— Optional edge weights. IfNone, each edge has weight 1.
§Examples
use rust_igraph::{Graph, cut_size};
let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
// Partition: {0,1} vs {2,3}
let membership = vec![0u32, 0, 1, 1];
let cs = cut_size(&g, &membership, None).unwrap();
assert!((cs - 1.0).abs() < 1e-10); // only edge 1-2 crosses