Skip to main content

link_pred_preferential_attachment

Function link_pred_preferential_attachment 

Source
pub fn link_pred_preferential_attachment(
    graph: &Graph,
    pairs: &[(VertexId, VertexId)],
) -> IgraphResult<Vec<f64>>
Expand description

Compute Preferential Attachment score for given vertex pairs.

For each pair (u, v), returns deg(u) × deg(v). Based on the preferential attachment model where high-degree nodes are more likely to form new connections.

§Examples

use rust_igraph::{Graph, link_pred_preferential_attachment};

let g = Graph::from_edges(
    &[(0,1),(0,2),(1,2),(1,3),(2,3)], false, Some(4)
).unwrap();
let scores = link_pred_preferential_attachment(&g, &[(0, 3)]).unwrap();
// deg(0)=2, deg(3)=2 → PA = 4
assert_eq!(scores[0], 4.0);