Skip to main content

get_shortest_paths_dijkstra_with_mode

Function get_shortest_paths_dijkstra_with_mode 

Source
pub fn get_shortest_paths_dijkstra_with_mode(
    graph: &Graph,
    source: VertexId,
    weights: &[f64],
    mode: DijkstraMode,
) -> IgraphResult<ShortestPathsDijkstra>
Expand description

Mode-aware get_shortest_paths_dijkstra.

For directed graphs, mode controls traversal direction. For undirected graphs, mode is ignored.

§Examples

use rust_igraph::{Graph, get_shortest_paths_dijkstra_with_mode, DijkstraMode};

// Directed 0→1→2 with unit weights.
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
let r = get_shortest_paths_dijkstra_with_mode(&g, 0, &[1.0, 1.0], DijkstraMode::Out).unwrap();
assert_eq!(r.vertex_paths[2], vec![0, 1, 2]);
assert_eq!(r.edge_paths[2], vec![0, 1]);