pub fn bond_percolation(
graph: &Graph,
edge_order: &[u32],
) -> IgraphResult<EdgelistPercolation>Expand description
Bond percolation: the size of the largest component as edges of
graph are added in the order specified by edge_order.
Returns an EdgelistPercolation with two vectors, both of
length edge_order.len() — same shape as
edgelist_percolation, just resolved from edge ids instead of
raw vertex pairs.
edge_order[i] must be a valid edge id (< graph.ecount()) and
must not repeat — duplicates return
IgraphError::InvalidArgument; out-of-range ids return
IgraphError::EdgeOutOfRange.
Edge direction is ignored (matches upstream — percolation reads edges as undirected connection events).
To shuffle into a random order, generate the permutation with
your own RNG and pass it as edge_order. We don’t take an RNG
here to keep the API deterministic and to avoid pulling in a
rand dependency for callers who already have one.
Counterpart of igraph_bond_percolation from
references/igraph/src/connectivity/percolation.c:214.
§Examples
use rust_igraph::{Graph, bond_percolation};
// Path 0-1-2-3 with edges added in natural id order.
let mut g = Graph::with_vertices(4);
g.add_edges(vec![(0u32, 1u32), (1, 2), (2, 3)]).unwrap();
let p = bond_percolation(&g, &[0, 1, 2]).unwrap();
assert_eq!(p.giant_size, vec![2, 3, 4]);
assert_eq!(p.vertex_count, vec![2, 3, 4]);