Skip to main content

expand_path_to_pairs

Function expand_path_to_pairs 

Source
pub fn expand_path_to_pairs(path: &[u32]) -> Vec<(u32, u32)>
Expand description

Expand a vertex path into consecutive pairs for edge lookup.

Converts [v0, v1, v2, v3] into [(v0, v1), (v1, v2), (v2, v3)]. Useful for converting a path of vertex IDs into pairs that can be passed to edge-lookup functions.

Returns an empty vector if the path has fewer than 2 elements.

ยงExamples

use rust_igraph::expand_path_to_pairs;

let path = vec![0, 1, 2, 3];
let pairs = expand_path_to_pairs(&path);
assert_eq!(pairs, vec![(0, 1), (1, 2), (2, 3)]);