Skip to main content

fiedler_vector

Function fiedler_vector 

Source
pub fn fiedler_vector(graph: &Graph) -> IgraphResult<Vec<f64>>
Expand description

Compute the Fiedler vector of a graph.

The Fiedler vector is the eigenvector corresponding to the algebraic connectivity λ_2(L). It provides a one-dimensional spectral embedding used for graph bisection.

Returns a vector of length vcount. For disconnected or single-vertex graphs, returns the zero vector.

§Examples

use rust_igraph::{Graph, fiedler_vector};

let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
let fv = fiedler_vector(&g).unwrap();
assert_eq!(fv.len(), 4);