pub fn frontier_sampling(
adjacency: &[Vec<usize>],
n_nodes: usize,
sample_size: usize,
rng_seed: u64,
) -> Result<Vec<usize>>Expand description
Frontier-based graph sampling.
Maintains a frontier set of nodes and at each step:
- Picks a random frontier node
u. - Picks a random neighbour
vofu. - If
vis not yet sampled, adds it to the sample and the frontier; ifvalready sampled, reinsertsuinto the frontier (Frontier Sampling per Stumpf et al. / Leskovec & Faloutsos 2006).
Frontier sampling preserves degree distribution better than naive random node or random edge sampling.
§Parameters
adjacency– unweighted adjacency list.n_nodes– total number of nodes (=adjacency.len()).sample_size– desired number of nodes in the sample.rng_seed– PRNG seed.
§Returns
Sorted Vec<usize> of sampled node indices (length ≤ sample_size).
§Errors
Returns GraphError::InvalidParameter if n_nodes is 0 or
sample_size > n_nodes.