|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Dial's algorithm for shortest paths with small integer weights. More...
#include <limits>#include <type_traits>#include <tpl_array.H>#include <tpl_graph_utils.H>#include <ah-errors.H>Go to the source code of this file.
Classes | |
| class | Aleph::Dial_Min_Paths< GT, Distance, Itor, SA > |
| Dial's algorithm for shortest paths with integer weights. More... | |
| struct | Aleph::Dial_Min_Paths< GT, Distance, Itor, SA >::Node_Info |
| class | Aleph::Dial_Min_Paths< GT, Distance, Itor, SA >::Dial_Init_Guard |
| RAII guard for Dial initialization and cleanup. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Macros | |
| #define | DIAL_INFO(p) (static_cast<Node_Info *>(NODE_COOKIE(p))) |
| #define | DIAL_DIST(p) (DIAL_INFO(p)->dist) |
| #define | DIAL_PARENT(p) (DIAL_INFO(p)->parent) |
| #define | DIAL_PARC(p) (DIAL_INFO(p)->parent_arc) |
Dial's algorithm for shortest paths with small integer weights.
Implements Dial's algorithm, a bucket-based variant of Dijkstra's algorithm optimized for graphs with non-negative integer edge weights. It achieves O(V + E + C) time complexity, where C is the maximum edge weight times the number of vertices.
Instead of a priority queue, Dial's algorithm uses an array of buckets indexed by distance. Each bucket holds the nodes at that distance from the source. The algorithm scans buckets in order, processing all nodes in the current bucket before moving to the next.
This is especially efficient when the maximum edge weight C is small, as the number of buckets is proportional to V * C.
| Operation | Time | Space |
|---|---|---|
| Single-target | O(V + E + V*C) | O(V + V*C) |
| All-targets | O(V + E + V*C) | O(V + V*C) |
where C is the maximum edge weight.
Definition in file Dial.H.
| #define DIAL_INFO | ( | p | ) | (static_cast<Node_Info *>(NODE_COOKIE(p))) |