pub fn reciprocity(graph: &Graph) -> IgraphResult<Option<f64>>Expand description
Reciprocity of graph. Returns None for graphs with no edges
(matches upstream’s IGRAPH_NAN).
Counterpart of igraph_reciprocity(_, _, /*ignore_loops=*/false, IGRAPH_RECIPROCITY_DEFAULT). For undirected graphs returns
Some(1.0) unconditionally.
§Examples
use rust_igraph::{Graph, reciprocity};
// Directed mutual pair: 0 -> 1, 1 -> 0. Both edges have a reverse → 1.0.
let mut g = Graph::new(2, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 0).unwrap();
assert_eq!(reciprocity(&g).unwrap(), Some(1.0));
// One-way: 0 -> 1 only. No reverse → 0.0.
let mut g = Graph::new(2, true).unwrap();
g.add_edge(0, 1).unwrap();
assert_eq!(reciprocity(&g).unwrap(), Some(0.0));