Skip to main content

hrg_predict

Function hrg_predict 

Source
pub fn hrg_predict(
    graph: &Graph,
    start_hrg: Option<&HrgTree>,
    num_samples: u64,
    seed: u64,
) -> IgraphResult<Vec<(u32, u32, f64)>>
Expand description

Predict missing edges based on HRG ensemble sampling.

Returns a list of (from, to, probability) tuples sorted by probability (highest first). Only non-existing edges are included.

The MCMC chain first runs a burn-in of 200*n steps, then samples with probability 1/(50*n) per step until num_samples trees have been collected.

§Errors

Returns an error if the graph has fewer than 3 vertices.

§Example

use rust_igraph::{Graph, hrg_predict};

let g = Graph::from_edges(
    &[(0,1),(1,2),(2,3),(3,4),(4,0)],
    false, Some(5)
).unwrap();
let predictions = hrg_predict(&g, None, 10, 42).unwrap();
assert!(!predictions.is_empty());
for &(from, to, prob) in &predictions {
    assert!(prob >= 0.0 && prob <= 1.0);
    assert!(from < to);
}