Skip to main content

forman_ricci_curvature

Function forman_ricci_curvature 

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

Forman-Ricci curvature for each edge.

For an unweighted, undirected edge (u, v), the Forman-Ricci curvature is: F(u,v) = 4 - deg(u) - deg(v) + 3 * triangles(u,v)

where triangles(u,v) is the number of triangles containing edge (u,v).

Positive curvature indicates the edge is in a locally dense region; negative curvature indicates a bridge-like structure.

ยงExamples

use rust_igraph::{Graph, forman_ricci_curvature};

// Triangle graph: each edge has F = 4 - 2 - 2 + 3*1 = 3
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let curv = forman_ricci_curvature(&g).unwrap();
assert!((curv[0] - 3.0).abs() < 1e-10);