|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Bellman-Ford algorithm for single-source shortest paths. More...
#include <type_traits>#include <limits>#include <vector>#include <tpl_dynListQueue.H>#include <tpl_dynSetTree.H>#include <tpl_graph_utils.H>#include <Tarjan.H>#include <ah-errors.H>#include <ah_init_guard.H>#include <cookie_guard.H>Go to the source code of this file.
Classes | |
| class | Aleph::Bellman_Ford< GT, Distance, Ait, NAit, SA > |
| Bellman-Ford algorithm for shortest paths with negative weights. More... | |
| struct | Aleph::Bellman_Ford< GT, Distance, Ait, NAit, SA >::Sni |
| struct | Aleph::Bellman_Ford< GT, Distance, Ait, NAit, SA >::Ni |
| struct | Aleph::Bellman_Ford_Negative_Cycle< GT, Distance, Ait, NAit, SA > |
| Detects if a negative cycle exists and eventually computes it. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Bellman-Ford algorithm for single-source shortest paths.
This file implements the Bellman-Ford algorithm, which computes the shortest paths from a single source vertex to all other vertices in a weighted directed graph. Unlike Dijkstra's algorithm, Bellman-Ford can handle graphs with negative edge weights and can detect negative-weight cycles.
| Operation | Time | Space |
|---|---|---|
| Standard | O(V*E) | O(V) |
| SPFA (avg) | O(E) | O(V) |
| SPFA (worst) | O(V*E) | O(V) |
Definition in file Bellman_Ford.H.