Skip to main content

correlated_pair_game

Function correlated_pair_game 

Source
pub fn correlated_pair_game(
    n: u32,
    corr: f64,
    p: f64,
    directed: bool,
    permutation: Option<&[VertexId]>,
    seed: u64,
) -> IgraphResult<(Graph, Graph)>
Expand description

Sample two random graphs with target adjacency-vector correlation corr. Builds graph1 via ER(n, p) and graph2 via correlated_game against graph1.

Counterpart of igraph_correlated_pair_game in references/igraph/src/games/correlated.c:330.

  • n — vertex count for both graphs.
  • corr — target correlation, in [0, 1].
  • p — marginal edge probability, in the open (0, 1).
  • directed — whether both graphs are directed.
  • permutation — optional, applied to graph2 only (see correlated_game).
  • seed — drives a single internal SplitMix64. graph1 consumes its initial draws; graph2 is sampled from the continuation.

§Errors

Same conditions as correlated_game, plus any error from crate::erdos_renyi_gnp when building graph1.

§Examples

use rust_igraph::correlated_pair_game;
let (g1, g2) = correlated_pair_game(40, 0.7, 0.2, false, None, 99).unwrap();
assert_eq!(g1.vcount(), 40);
assert_eq!(g2.vcount(), 40);