pub fn dot_product_game_with_warnings(
vecs: &[Vec<f64>],
directed: bool,
seed: u64,
) -> IgraphResult<(Graph, DotProductWarnings)>Expand description
Sample a random dot-product graph from caller-supplied latent position vectors and report whether clamp regimes were hit.
vecs[i]is the latent position vector for vertexi. The slice length determines the resulting graph’s vertex countn. All entries must be finite (no NaN, no±∞); every vector must share the same dimensiond.directed— whentrue, both(i, j)and(j, i)are sampled independently with their own dot product (the matrix need not be symmetric — even though the dot product itself is, the draws are distinct). Whenfalse, onlyi < jpairs are sampled.seedinitialises an internalSplitMix64PRNG so the output is reproducible given the inputs.
Returns the generated graph together with DotProductWarnings
flags so the caller can decide whether to log/abort/clip when the
latent positions stray outside [0, 1].
§Errors
vecs[i].len() != vecs[0].len()for somei— every latent vector must share the same dimension.- Any entry is non-finite (NaN or
±∞). vecs.len() > u32::MAX.
§Complexity
O(n² · d) — every pair is inspected exactly once, each with a
length-d dot product. The RNG-draw count is at most one per pair
and is strictly less when the prob > 1 short-circuit fires.
§Examples
use rust_igraph::dot_product_game_with_warnings;
// Three vertices on the unit interval (1-D latent space).
// p_{0,1} = 0.4·0.6 = 0.24; p_{0,2} = 0.4·0.5 = 0.20; p_{1,2} = 0.30.
let vecs = vec![vec![0.4], vec![0.6], vec![0.5]];
let (g, warn) = dot_product_game_with_warnings(&vecs, false, 42).unwrap();
assert_eq!(g.vcount(), 3);
assert!(!g.is_directed());
assert!(!warn.had_negative);
assert!(!warn.had_over_one);