pub fn expand_path_to_pairs(
path: &[VertexId],
) -> Result<Vec<(VertexId, VertexId)>>Expand description
Turns a path given as a vertex sequence into the list of its consecutive
vertex pairs, e.g. [a, b, c] into [(a, b), (b, c)].
The result can be passed to Graph::get_eids to find the edges along
the path. Paths with fewer than two vertices give an empty list.
Binds igraph_expand_path_to_pairs.
ยงExamples
use igraph::{paths::expand_path_to_pairs, prelude::*};
assert_eq!(expand_path_to_pairs(&[0, 4, 2]).unwrap(), vec![(0, 4), (4, 2)]);
assert!(expand_path_to_pairs(&[7]).unwrap().is_empty());
let g = Graph::from_edges(&[(0, 4), (4, 2)], 5, false).unwrap();
let pairs = expand_path_to_pairs(&[0, 4, 2]).unwrap();
// Graph::get_eids (core) turns the pairs into edge ids.
assert_eq!(g.get_eids(&pairs, false).unwrap(), vec![0, 1]);