pub fn are_adjacent(
graph: &Graph,
v1: VertexId,
v2: VertexId,
) -> IgraphResult<bool>Expand description
Check whether two vertices are connected by at least one edge.
For directed graphs, checks if there is an edge from v1 to v2
or from v2 to v1 (i.e. direction is ignored, matching the
C implementation which uses IGRAPH_DIRECTED but still checks
adjacency in both directions for undirected queries).
§Errors
- Returns an error if either
v1orv2is out of range.
§Examples
use rust_igraph::{Graph, are_adjacent};
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(2, 3).unwrap();
assert!(are_adjacent(&g, 0, 1).unwrap());
assert!(!are_adjacent(&g, 0, 2).unwrap());