pub fn adjacency_spectral_embedding(
graph: &Graph,
no: usize,
weights: Option<&[f64]>,
which: SpectralWhich,
scaled: bool,
cvec: Option<&[f64]>,
) -> IgraphResult<AdjacencySpectralEmbeddingResult>Expand description
Compute the adjacency spectral embedding of an undirected graph.
Decomposes the (optionally augmented) adjacency matrix A + diag(cvec) into its top eigenpairs and returns the eigenvectors as vertex embeddings.
no: embedding dimension (number of eigenpairs to compute).
weights: optional edge weights. Must have length ecount if
provided.
which: which eigenvalues to use. SpectralWhich::LargestAlgebraic
is the default in igraph.
scaled: if true, multiply each eigenvector column by
sqrt(|eigenvalue|), giving X = U D^(1/2).
cvec: optional diagonal augmentation vector. If Some(&[c]) (a
single element), c is added to every diagonal entry. If
Some(&[c0, c1, ..., cn-1]) (length = vcount), vertex i gets
c_i added to its diagonal. Default is zero augmentation.
Edge directions are ignored (the graph is treated as undirected).
ยงExamples
use rust_igraph::{Graph, adjacency_spectral_embedding, SpectralWhich};
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();
let r = adjacency_spectral_embedding(&g, 2, None, SpectralWhich::LargestAlgebraic,
false, None).unwrap();
assert_eq!(r.eigenvalues.len(), 2);
assert_eq!(r.embedding.len(), 4);
assert_eq!(r.embedding[0].len(), 2);