|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
0-1 BFS shortest path algorithm. More...
#include <limits>#include <type_traits>#include <tpl_dynDlist.H>#include <tpl_graph_utils.H>#include <ah-errors.H>Go to the source code of this file.
Classes | |
| class | Aleph::Zero_One_BFS< GT, Distance, Itor, SA > |
| 0-1 BFS algorithm for shortest paths in graphs with 0/1 weights. More... | |
| struct | Aleph::Zero_One_BFS< GT, Distance, Itor, SA >::Node_Info |
| struct | Aleph::Zero_One_BFS< GT, Distance, Itor, SA >::Painted_Info |
| Stores parent and distance after painting for O(1) access. More... | |
| class | Aleph::Zero_One_BFS< GT, Distance, Itor, SA >::ZOB_Init_Guard |
| RAII guard for Zero_One_BFS initialization and cleanup. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Macros | |
| #define | ZOB_INFO(p) (static_cast<Node_Info *>(NODE_COOKIE(p))) |
| #define | ZOB_PNTD(p) (static_cast<Painted_Info *>(NODE_COOKIE(p))) |
| #define | ZOB_DIST(p) (ZOB_INFO(p)->dist) |
| #define | ZOB_PARENT(p) (ZOB_INFO(p)->parent) |
| #define | ZOB_PARENT_ARC(p) (ZOB_INFO(p)->parent_arc) |
0-1 BFS shortest path algorithm.
Implements the 0-1 BFS algorithm for finding shortest paths in graphs where all edge weights are either 0 or 1. Uses a double-ended queue (deque) to achieve O(V + E) time complexity, which is optimal for this class of graphs.
Instead of a priority queue (as in Dijkstra), 0-1 BFS uses a deque:
This maintains the invariant that the deque is sorted by distance, so the front always contains the node with minimum distance.
| Operation | Time | Space |
|---|---|---|
| Single-target | O(V + E) | O(V) |
| All-targets | O(V + E) | O(V) |
Definition in file Zero_One_BFS.H.
| #define ZOB_DIST | ( | p | ) | (ZOB_INFO(p)->dist) |
Definition at line 167 of file Zero_One_BFS.H.
| #define ZOB_INFO | ( | p | ) | (static_cast<Node_Info *>(NODE_COOKIE(p))) |
Definition at line 165 of file Zero_One_BFS.H.
| #define ZOB_PARENT | ( | p | ) | (ZOB_INFO(p)->parent) |
Definition at line 168 of file Zero_One_BFS.H.
| #define ZOB_PARENT_ARC | ( | p | ) | (ZOB_INFO(p)->parent_arc) |
Definition at line 169 of file Zero_One_BFS.H.
| #define ZOB_PNTD | ( | p | ) | (static_cast<Painted_Info *>(NODE_COOKIE(p))) |
Definition at line 166 of file Zero_One_BFS.H.