pub fn sample_negative_edges_excluding(
graph: &Graph,
count: usize,
exclude: &[(VertexId, VertexId)],
seed: u64,
) -> IgraphResult<Vec<(VertexId, VertexId)>>Expand description
Sample negative edges avoiding a set of positive edges.
Like sample_negative_edges but also avoids generating pairs
that appear in an additional exclude set. Useful when you have
a train/test split and want negatives that don’t overlap with
either set.
§Examples
use rust_igraph::{Graph, sample_negative_edges_excluding};
let g = Graph::from_edges(
&[(0,1),(1,2),(2,3),(3,4)], false, Some(5)
).unwrap();
// Also exclude edge 0-4 from negatives
let exclude = vec![(0, 4)];
let neg = sample_negative_edges_excluding(&g, 3, &exclude, 42).unwrap();
for &(u, v) in &neg {
assert!(!g.has_edge(u, v));
assert_ne!((u, v), (0, 4));
}