pub fn spectral_bisection(graph: &Graph) -> IgraphResult<Vec<u32>>Expand description
Compute a spectral bisection of the graph.
Partitions vertices into two groups based on the sign of the Fiedler vector: vertices with non-negative entries go to group 0, vertices with negative entries go to group 1.
Returns a membership vector of length vcount with values 0 or 1.
ยงExamples
use rust_igraph::{Graph, spectral_bisection};
// Path 0-1-2-3: natural split at the middle
let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
let parts = spectral_bisection(&g).unwrap();
assert_eq!(parts.len(), 4);
// Each part should be non-empty
assert!(parts.iter().any(|&p| p == 0));
assert!(parts.iter().any(|&p| p == 1));