Skip to main content

effective_resistance_matrix

Function effective_resistance_matrix 

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

Compute the effective resistance matrix for all pairs.

Returns a flattened n × n matrix in row-major order where entry (u,v) is the effective resistance R(u,v).

§Examples

use rust_igraph::{Graph, effective_resistance_matrix};

let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
let r = effective_resistance_matrix(&g).unwrap();
// R(0,1) = 1, R(1,2) = 1, R(0,2) = 2
assert!((r[0 * 3 + 1] - 1.0).abs() < 0.01);
assert!((r[0 * 3 + 2] - 2.0).abs() < 0.01);