Skip to main content

communicability_matrix

Function communicability_matrix 

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

Compute the communicability matrix between all pairs of vertices.

C(u,v) = (e^A)_{uv} = Σ_j φ_j(u) · φ_j(v) · exp(λ_j)

Returns a flattened n × n matrix in row-major order. The diagonal entries equal the subgraph centrality.

§Errors

Returns IgraphError::InvalidArgument if the graph has more than 10 000 vertices (the output would be impractical).

§Examples

use rust_igraph::{Graph, communicability_matrix};

let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
let c = communicability_matrix(&g).unwrap();
// Symmetric: C(0,1) == C(1,0)
assert!((c[0 * 3 + 1] - c[1 * 3 + 0]).abs() < 1e-10);
// Diagonal = subgraph centrality
assert!(c[0] > 0.0);