pub fn similarity_inverse_log_weighted_pairs(
graph: &Graph,
pairs: &[(VertexId, VertexId)],
) -> IgraphResult<Vec<f64>>Expand description
Computes the inverse log-weighted (Adamic-Adar) similarity for given vertex pairs.
The Adamic-Adar index of two vertices u and v is:
sum_{w in N(u) ∩ N(v)} 1 / log(deg(w))
where the sum runs over all common neighbors. High-degree common neighbors contribute less, reflecting that a shared low-degree neighbor is more informative. Isolated vertices have zero similarity to any other vertex.
§Arguments
graph— the input graph (treated as undirected for neighbor lookup).pairs— slice of(u, v)vertex pairs to compute similarity for.
§Examples
use rust_igraph::{Graph, similarity_inverse_log_weighted_pairs};
let mut g = Graph::with_vertices(4);
g.add_edge(0, 2).unwrap();
g.add_edge(0, 3).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(1, 3).unwrap();
let sim = similarity_inverse_log_weighted_pairs(&g, &[(0, 1)]).unwrap();
// Common neighbors: 2 (deg=2), 3 (deg=2)
// AA = 1/ln(2) + 1/ln(2) = 2/ln(2)
assert!((sim[0] - 2.0 / 2.0_f64.ln()).abs() < 1e-10);