pub fn correlated_game(
old_graph: &Graph,
corr: f64,
p: f64,
permutation: Option<&[VertexId]>,
seed: u64,
) -> IgraphResult<Graph>Expand description
Generate a random graph whose adjacency vector is Pearson-correlated
to that of old_graph at level corr.
old_graph— input. Must be simple (no self-loops, no multi-edges). Vertex countnanddirectedare inherited.corr— target correlation, in[0, 1].0is independent (sampled fromER(n, p));1is a relabeled copy ofold_graph.p— marginal edge probability, in the open(0, 1). Usually matches the empirical density ofold_graph.permutation— optional vertex relabeling.perm[i]names the vertex inold_graphthat becomes vertexiin the new graph. Must be a bijection of[0, n).seed— drives the internalSplitMix64PRNG.
§Errors
corrnot in[0, 1],pnot in(0, 1), either is NaN/∞;permutation.len() != old_graph.vcount();permutationis not a bijection of[0, n);old_graphis not simple.
§Examples
use rust_igraph::{Graph, correlated_game, erdos_renyi_gnp};
let old = erdos_renyi_gnp(20, 0.3, false, false, 11).unwrap();
// Strong correlation: most of old's edges survive.
let new_g = correlated_game(&old, 0.9, 0.3, None, 17).unwrap();
assert_eq!(new_g.vcount(), 20);
assert_eq!(new_g.is_directed(), false);