Function petgraph::algo::bellman_ford
source · pub fn bellman_ford<G>(
g: G,
source: G::NodeId,
) -> Result<(Vec<G::EdgeWeight>, Vec<Option<G::NodeId>>), NegativeCycle>
Expand description
[Generic] Compute shortest paths from node source
to all other.
Using the Bellman–Ford algorithm; negative edge costs are permitted, but the graph must not have a cycle of negative weights (in that case it will return an error).
On success, return one vec with path costs, and another one which points out the predecessor of a node along a shortest path. The vectors are indexed by the graph’s node indices.