Skip to main content

get_eids

Function get_eids 

Source
pub fn get_eids(
    graph: &Graph,
    pairs: &[(VertexId, VertexId)],
    error: bool,
) -> IgraphResult<Vec<Option<u32>>>
Expand description

Look up edge IDs for a batch of vertex pairs.

Each element (from, to) in pairs is resolved to the corresponding edge ID. If no edge exists for a given pair, the result depends on error: when true, the function returns an error; when false, the missing entry is None.

Counterpart of igraph_get_eids from references/igraph/src/graph/type_indexededgelist.c.

ยงExamples

use rust_igraph::{Graph, get_eids};

let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap(); // eid 0
g.add_edge(1, 2).unwrap(); // eid 1
g.add_edge(2, 3).unwrap(); // eid 2

let eids = get_eids(&g, &[(0, 1), (2, 3)], true).unwrap();
assert_eq!(eids, vec![Some(0), Some(2)]);