This is documentation for an old release of SciPy (version 0.12.0). Read this page in the documentation of the latest stable release (version 1.15.1).
Compute the shortest path lengths using the Bellman-Ford algorithm.
The Bellman-ford algorithm can robustly deal with graphs with negative weights. If a negative cycle is detected, an error is raised. For graphs without negative edge weights, dijkstra’s algorithm may be faster.
Parameters : | csgraph : array, matrix, or sparse matrix, 2 dimensions
directed : bool, optional
indices : array_like or int, optional
return_predecessors : bool, optional
unweighted : bool, optional
|
---|---|
Returns : | dist_matrix : ndarray
predecessors : ndarray
|
Raises : | NegativeCycleError: :
|
Notes
This routine is specially designed for graphs with negative edge weights. If all edge weights are positive, then Dijkstra’s algorithm is a better choice.