pub fn vertex_path_from_edge_path(
graph: &Graph,
start: Option<u32>,
edge_path: &[u32],
mode: WalkMode,
) -> IgraphResult<Vec<u32>>Expand description
Convert an edge path to a vertex path.
Given a sequence of edge IDs forming a continuous walk starting at
start, returns the sequence of vertex IDs traversed. The result
always has edge_path.len() + 1 elements.
If start is None, the start vertex is inferred from the first
edge (requires at least one edge). For directed graphs with WalkMode::Out,
the source of the first edge is used; for In, the target is used.
For undirected graphs or All mode with multiple edges, the vertex
connecting the first two edges is determined.
The mode parameter is ignored for undirected graphs (treated as All).
§Errors
InvalidArgumentifstartis out of range.InvalidArgumentifstartisNoneandedge_pathis empty.InvalidArgumentif the edge IDs do not form a continuous path.
§Examples
use rust_igraph::{Graph, vertex_path_from_edge_path, WalkMode};
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 vpath = vertex_path_from_edge_path(&g, Some(0), &[0, 1, 2], WalkMode::All).unwrap();
assert_eq!(vpath, vec![0, 1, 2, 3]);