Expand description
§Tide Flow
Implementation of the Tide max flow algorithm — a push-pull-relabel variant.
The algorithm performs global sweeps (BFS relabeling, then global pull, then
global push) in each iteration (“tide”). It uses O(1) array-based data
structures with i64 capacities for maximum performance.
§Algorithm Overview
Each tide consists of three phases:
- globalRelabel — BFS from source and sink on the residual graph to compute exact vertex heights.
- globalPull — Right-fold over overflowing vertices (descending level), pulling flow on reverse edges.
- globalPush — Left-fold over overflowing vertices (ascending level), pushing flow on forward edges.
Terminates when net flow and the overflowing set are unchanged between tides.
§Optimizations
- Skips
globalRelabelwhen no edge crossed a saturation boundary. - Precomputed level buckets (levels are constant).
- Contiguous adjacency storage (CSR-like head/next arrays).
- Reused BFS buffers across tides.
- Allocation-free convergence check via excess hash.
Structs§
- MaxFlow
Result - Result of the Tide max flow computation.
- Phase
Timing - Per-phase timing breakdown (in microseconds) for profiling.
- Timed
MaxFlow Result - Result with timing breakdown.
Functions§
- max_
flow - Compute the maximum flow in a network using the Tide algorithm.
- max_
flow_ adaptive - Compute max flow using adaptive Tide.
- max_
flow_ adaptive_ timed - Compute max flow using adaptive Tide with per-phase timing.
- max_
flow_ hybrid - Compute max flow using the hybrid Tide algorithm.
- max_
flow_ hybrid_ timed - Compute max flow using the hybrid Tide algorithm with timing.
- max_
flow_ timed - Compute max flow with per-phase timing instrumentation.