pub fn dijkstra_distances(
graph: &Graph,
source: VertexId,
weights: &[f64],
) -> IgraphResult<Vec<Option<f64>>>Expand description
Single-source Dijkstra distances.
Returns Vec<Option<f64>> of length vcount: result[v] = Some(d)
if there is a path from source to v with weighted distance d,
None if v is unreachable. The source’s own distance is
Some(0.0) whenever source is a valid vertex.
weights[e] is the weight of edge e; weights.len() must equal
graph.ecount(). All weights must be >= 0 and finite (no NaN, no
infinity).
§Examples
use rust_igraph::{Graph, dijkstra_distances};
// Triangle 0-1-2 with weights 1, 4, 2 → dist(0→2) = 1+2 via 0-1-2
// (3.0) is shorter than the direct 0-2 edge weight 4.0.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap(); // edge 0, weight 1
g.add_edge(0, 2).unwrap(); // edge 1, weight 4
g.add_edge(1, 2).unwrap(); // edge 2, weight 2
let d = dijkstra_distances(&g, 0, &[1.0, 4.0, 2.0]).unwrap();
assert_eq!(d, vec![Some(0.0), Some(1.0), Some(3.0)]);