pub fn get_shortest_paths_dijkstra(
graph: &Graph,
source: VertexId,
weights: &[f64],
) -> IgraphResult<ShortestPathsDijkstra>Expand description
Returns one shortest path from source to every vertex in the
graph, using weighted edges (Dijkstra’s algorithm).
For directed graphs, follows edges in the outgoing direction by
default. Use get_shortest_paths_dijkstra_with_mode to control
direction.
§Errors
InvalidArgumentifsource >= vcount(), or weights are invalid (wrong length, negative, or NaN).
§Examples
use rust_igraph::{Graph, get_shortest_paths_dijkstra};
// Path 0-1-2-3, weights [1, 1, 1, 10] — last edge is a heavy shortcut.
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(0, 3).unwrap(); // heavy
let r = get_shortest_paths_dijkstra(&g, 0, &[1.0, 1.0, 1.0, 10.0]).unwrap();
assert_eq!(r.vertex_paths[3], vec![0, 1, 2, 3]);
assert_eq!(r.edge_paths[3], vec![0, 1, 2]);