pub fn induced_subgraph_edges(
graph: &Graph,
vids: &[u32],
) -> IgraphResult<Vec<u32>>Expand description
Returns the IDs of edges whose both endpoints lie in vids.
This is a lightweight alternative to crate::induced_subgraph when
you only need the edge list, not the full subgraph structure. It’s
useful for counting or iterating over edges within a vertex subset.
The returned edge IDs are sorted in ascending order. Duplicate vertex
IDs in vids are silently ignored.
§Errors
Returns InvalidArgument if any vertex ID in vids is out of range.
§Examples
use rust_igraph::{Graph, induced_subgraph_edges};
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap(); // eid 0
g.add_edge(1, 2).unwrap(); // eid 1
g.add_edge(2, 3).unwrap(); // eid 2
g.add_edge(3, 4).unwrap(); // eid 3
g.add_edge(0, 4).unwrap(); // eid 4
// Edges within {0, 1, 2}: only 0-1 and 1-2
let edges = induced_subgraph_edges(&g, &[0, 1, 2]).unwrap();
assert_eq!(edges, vec![0, 1]);