pub fn bellman_ford_distances_with_mode(
graph: &Graph,
source: VertexId,
weights: &[f64],
mode: DijkstraMode,
) -> IgraphResult<Vec<Option<f64>>>Expand description
Single-source Bellman-Ford with directed-mode selection.
mode selects how directed edges are followed:
DijkstraMode::Outfollows out-edges (default forbellman_ford_distances),DijkstraMode::Infollows in-edges (i.e. shortest paths intosource),DijkstraMode::Allignores edge direction.
On undirected graphs the mode is ignored.
Counterpart of igraph_distances_bellman_ford(_, _, vss(source), vss_all(), weights, mode).
ยงExamples
use rust_igraph::{Graph, bellman_ford_distances_with_mode, DijkstraMode};
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
let d = bellman_ford_distances_with_mode(&g, 2, &[1.0, 1.0], DijkstraMode::In).unwrap();
assert!((d[0].unwrap() - 2.0).abs() < 1e-9);