hyper_sssp#
shortest hyperpaths. The algorithm page is hyper_sssp: shortest hyperpaths; the tutorial is Shortest hyperpaths.
The header is frozen since the end of M11b (ADR 0096: The hyper_sssp API review and freeze (0.4);
maturity stable in its manifest): a removed or changed declaration needs the api-change label
and a CHANGELOG entry. It is stable from 0.4.0 (SemVer, PLAN 5.9; the author’s decision of
2026-11-18 on HD17, GOVERNANCE.md), with the slack_csr storage and the incidence edits of the
hypergraph it reads (Hypergraphs). Its oracle, <dyng/testing/hyper_sssp_reference.hpp>
(Testing oracles), stays tracked, not frozen, outside the stable tier.
-
enum class dyng::hyper_sssp::budget_action : std::uint8_t#
What update() does when its work or iteration budget is spent (options::on_budget).
Values:
-
enumerator recompute#
recompute from scratch (stats::fallback_used = true): the result is exact
-
enumerator error#
throw convergence_error; the budget is counted after the commit, so the hypergraph keeps the batch and the result is poisoned (the basic guarantee)
-
enumerator recompute#
-
enum class dyng::hyper_sssp::fallback_reason : std::uint8_t#
Why an update fell back to a recompute (stats::fallback_reason).
Values:
-
enumerator none#
no fallback
-
enumerator work_budget#
the relaxations exceeded options::work_budget x the live entries
-
enumerator iterations#
the push rounds reached options::max_iterations (cuda)
-
enumerator distance_width#
a distance did not fit the engine’s packed word (cuda; engine::fused: 32 bits; engine::operators: the bits next to the parent’s, see the work budget of hyper_sssp)
-
enumerator invalidation_depth#
the pointer jumping of the invalidation did not end within its rounds (cuda; engine::fused: 64; engine::operators: ceil(log2 n) + 1)
-
enumerator none#
-
std::string_view dyng::hyper_sssp::to_string(budget_action a) noexcept#
The lower-case name of a budget action (“recompute”, “error”).
- Parameters:
a – [in] The action.
- Returns:
A static string naming
a.
-
std::string_view dyng::hyper_sssp::to_string(fallback_reason r) noexcept#
The lower-case name of a fallback reason (“none”, “work_budget”, “iterations”, “distance_width”, “invalidation_depth”).
- Parameters:
r – [in] The reason.
- Returns:
A static string naming
r.
-
template<typename vertex_t, typename weight_t>
result<vertex_t> dyng::hyper_sssp::compute(const resources &res, const hypergraph<vertex_t, weight_t> &h, vertex_t source, const options &opt = {})# Compute the shortest hyperpaths of
hfrom the source vertexsource(the static solve, the oracle of update()).Every hyperedge that contains
sourcestarts at its own weight with parent -1; then rounds of pulls (every candidate takes its best (distance, lowest id) neighbour) and collections (the neighbours of the improved hyperedges become the next candidates) run until nothing improves: MOSP_ESCHER’s hsospRecompute on cuda under engine::fused (one warp per candidate) and emulateSospRecompute on sequential; engine::operators solves it with sssp’s near-far loop over the line graph (node weights). All give the canonical tree.- Synchronization:
Blocks until the work has completed (synchronous). On cuda the stream is synchronized once per round of the recompute.
- Backends:
sequential, cuda
- Determinism:
Bit-exact across backends and runs: the canonical tree (lowest-id ties).
- Exception safety:
Strong:
his not modified (its line graph may be built under line_graph_policy::automatic), and nothing is kept if the call throws.- Paper:
H-SOSP (IA3 2026):
dyng::citation("hyper_sssp"), key hsosp2026 in docs/references.bib.
- Template Parameters:
vertex_t – Vertex id type (int32_t).
weight_t – Hyperedge weight type (int32_t).
- Parameters:
res – [in] Execution resources (sequential or cuda).
h – [in] The hypergraph (see “Hypergraph requirements” of hyper_sssp; built with, or cloned for, the backend of
res); it is not modified (under line_graph_policy::automatic its line graph is built here, once).source – [in] The source vertex, in [0, num_vertices()).
opt – [in] Options.
- Throws:
invalid_argument_error – if
sourceis out of range, an option is invalid, a live weight is outside [1, 2^28] (validate_inputs),hkeeps no vertex-to-hyperedge rows (store_v2h = false),hbelongs to another backend thanres, orhwas poisoned by a failed apply().not_supported_error – if the backend of
resis openmp (hyper_sssp runs on sequential and cuda in 0.4; use dyng::resources::sequential()) or not built, orhis not slack_csr storage with its line graph (escher storage, or line_graph_policy::none).out_of_memory_error – if host or device memory cannot be allocated.
cuda_error – if the CUDA runtime reports an error.
- Returns:
The result, matching
h.version().
-
template<typename vertex_t, typename weight_t>
stats dyng::hyper_sssp::update(const resources &res, hypergraph<vertex_t, weight_t> &h, const hyperedge_batch_view<vertex_t, weight_t> &batch, result<vertex_t> &r)# Apply a batch of hyperedge and incidence changes to
hand update the shortest hyperpathsr.The batch is applied once (hypergraph::apply, with the line-graph delta inside its commit); then the result is updated from the delta (see hyper_sssp). Postcondition:
requals compute(res, h, r.source(), r.get_options()) exactly, distances and parents.- Synchronization:
Blocks until the work has completed (synchronous). On cuda the stream is synchronized once per push round (the engine reads its counters) and, under engine::fused, once per pointer-jumping round, plus the commit’s own synchronizations.
- Backends:
sequential, cuda
- Determinism:
Bit-exact across backends and runs (distances, parents,
invalidated, the line graph counts); fallback_used, fallback_reason, relaxations and iterations are schedule-dependent on cuda (see stats).- Exception safety:
Strong for every error found before the batch is applied:
handrare unchanged. Basic for an error inside the commit (his poisoned, as hypergraph::apply;ris unchanged and must be recomputed oncehis rebuilt) and after it (a spent budget under budget_action::error, a CUDA or allocation failure:hholds the new version andris poisoned, so every later use of it throws stale_result_error until it is recomputed).- Paper:
H-SOSP (IA3 2026):
dyng::citation("hyper_sssp").
- Template Parameters:
vertex_t – Vertex id type (int32_t).
weight_t – Hyperedge weight type (int32_t).
- Parameters:
res – [in] Execution resources (sequential or cuda;
handrmust belong to their backend).h – [inout] The hypergraph; the batch is applied to it and its version increases by one.
batch – [in] Hyperedge deletions (by id) and insertions, incidence removals and additions (host memory, or device memory under the copy policy of
res).r – [inout] Result of compute() or of a previous update() on
h.
- Throws:
stale_result_error – if r.graph_version() != h.version(),
rwas computed on another hypergraph, orrwas left unusable by a failed update.invalid_argument_error – if a batch id, member or weight is invalid (an inserted weight outside [1, 2^28] with validate_inputs),
hbelongs to another backend thanres, orhwas poisoned (nothing is changed).not_supported_error – as compute() (nothing is changed).
convergence_error – under budget_action::error, if the update exceeds its work or iteration budget (after the commit:
hholds the new version andris poisoned).capacity_error – if the hypergraph’s storage cannot hold the batch (as hypergraph::apply).
out_of_memory_error – if host or device memory cannot be allocated (before the commit: nothing is changed; inside it:
his poisoned; after it:ris poisoned).cuda_error – if the CUDA runtime reports an error.
- Returns:
Counters of this update (see stats for which are deterministic).
-
DYNG_HYPER_SSSP_TYPES_MESSAGE#
The message of hyper_sssp’s static_assert for an unsupported hypergraph type.
-
DYNG_HYPER_SSSP_CONTAINER_MESSAGE#
The message of hyper_sssp’s static_assert for a container that is not a hypergraph.
-
struct options#
- #include <dyng/hyper_sssp.hpp>
Options of compute() and update() (an aggregate; fields are only ever appended).
Every field is a tunable: it changes how an update runs, never its result, and result::set_options() changes it.
Public Members
-
double work_budget = 1.0#
The work budget of an update, as a multiple of the live line-graph entries (MOSP_ESCHER’s UpdateConfig::workBudget): before each push round (cuda) or expansion (sequential), an update whose relaxations exceed work_budget x max(1, live entries) takes the on_budget action. The work before the first check (the invalidation, the seed’s pulls and offers) is never refused: an update whose work all lies in its seed completes even at 0, and 0 acts at the first push round or expansion; +infinity never acts. Finite, or +infinity, and >= 0.
-
std::int64_t max_iterations = 4096#
The push rounds an update may run before the on_budget action (MOSP_ESCHER’s maxIterations; cuda only: the host engine has no rounds). Also the floor of the recompute’s round cap, max(max_iterations, hyperedge id bound + 1). At least 1.
-
budget_action on_budget = budget_action::recompute#
What an update does when it exceeds work_budget or max_iterations (the 32-bit width and the invalidation depth always recompute).
-
engine cuda_engine = engine::automatic#
The CUDA engine: automatic and fused run MOSP_ESCHER’s kernels (engine::fused); engine::operators runs the shared sssp engine (the same results). Ignored by the sequential backend.
-
bool validate_inputs = true#
Check the weights against [1, 2^28] (compute(): every live hyperedge; update(): the batch’s insertions, before the commit). Without the check heavier weights still give exact results (they fall back more often: fallback_reason::distance_width).
-
double work_budget = 1.0#
-
struct stats : public dyng::update_stats#
- #include <dyng/hyper_sssp.hpp>
Counters of one update() (fields are only ever appended).
The inherited fields mean:
affected: the hyperedges whose subtree was invalidated (= invalidated; deterministic);iterations: the push rounds (cuda) or the expansions (sequential) of Step 2; schedule-dependent on cuda, logged only, and engine-dependent asrelaxations;frontier_visits: the largest frontier (cuda) or the expansions (sequential); schedule-dependent on cuda;fallback_used: the update fell back to a recompute. Deterministic on sequential; schedule-dependent on cuda near the budget: the relaxations of a push round depend on the thread schedule, so a batch within a few percent of its budget may fall back in one run and not in another, with identical results (HD7; the weaker level core/stats.hpp allows); the two CUDA engines countrelaxationsdifferently on equal-distance ties, so their decisions near the budget can also differ from each other;converged: always true;engine_used: the CUDA engine that ran (options::cuda_engine; automatic is fused), and engine::operators on sequential.
Public Members
-
hyper_apply_summary batch#
Deterministic: what applying the batch did to the hypergraph (the inserted ids among it).
-
std::int64_t line_graph_insertions = 0#
Deterministic: the line-graph pairs the batch added.
-
std::int64_t line_graph_deletions = 0#
Deterministic: the line-graph pairs the batch removed.
-
std::int64_t invalidated = 0#
Deterministic: the hyperedges in invalidated subtrees (the source excluded).
-
std::int64_t relaxations = 0#
The relaxations the budget counted (the neighbours read by the pulls and pushes). Schedule-dependent on cuda; deterministic on sequential. Engine-dependent: engine::fused (MOSP_ESCHER’s relax) pushes a hyperedge again whenever its packed word drops, a smaller parent id at an equal distance included, engine::operators only when its distance drops, so on inputs with equal-distance ties the shared engine counts fewer relaxations and push rounds (the results are the same bit for bit).
-
hyper_sssp::fallback_reason fallback_reason = hyper_sssp::fallback_reason::none#
Why the update fell back (fallback_reason::none if it did not); schedule-dependent on cuda near the budget, as fallback_used.
-
template<typename vertex_t, typename distance_t = std::int64_t>
class result# - #include <dyng/hyper_sssp.hpp>
Shortest hyperpaths from one source vertex, kept up to date by update() (opaque, move-only).
The result owns its distance and parent arrays by hyperedge id (host memory, or device memory for the cuda backend), its options, the hypergraph version it matches, and on cuda the engine’s device state (MOSP_ESCHER’s HsospState: the packed words, the invalidation and frontier arrays).
Thread safety. A result is not thread-safe. Its accessors may run concurrently with each other, except distance_to() and vertex_distances(): they fill caches of the result (the vertex distances, and on cuda a host copy of the hyperedge distances) on their first call per hypergraph version, and read the hypergraph, so neither may overlap another call on the result or a change of its hypergraph. No call may overlap an update() of the result (or a dyng::update() that includes it), which must also not overlap another call on its hypergraph.
- Template Parameters:
vertex_t – Vertex id type (int32_t).
distance_t – Distance type: std::int64_t, the only width (another value fails to compile).
Public Functions
-
result(result &&other) noexcept#
Move constructor.
- Parameters:
other – [inout] The result to move from; it may only be assigned to or destroyed after.
-
result &operator=(result &&other) noexcept#
Move assignment.
- Parameters:
other – [inout] The result to move from; it may only be assigned to or destroyed after.
- Returns:
*this.
-
~result()#
releases the arrays
-
vertex_t source() const noexcept#
The source vertex.
- Returns:
The source given to compute() (invalid_id() for a moved-from result).
-
array_view<const distance_t> hyperedge_distances() const#
The distances D(h) by hyperedge id.
- Throws:
invalid_argument_error – for a moved-from result.
stale_result_error – if a failed update left the result unusable (poisoned).
- Returns:
hyperedge_id_bound() values of the hypergraph the result matches (host memory; device memory for a result of the cuda backend); infinite_distance<distance_t>() for dead or unreachable ids. Valid until the next update() of this result.
-
array_view<const std::int32_t> hyperedge_parents() const#
The canonical parents by hyperedge id (the shortest-hyperpath tree).
- Throws:
invalid_argument_error – for a moved-from result.
stale_result_error – if a failed update left the result unusable (poisoned).
- Returns:
As many values as hyperedge_distances() (in its memory space): 0-based hyperedge ids; -1 for a hyperedge reached directly from the source vertex, and for dead or unreachable ids. Hyperedge ids of slack_csr storage are below 2^31, so they are 32-bit. Valid until the next update().
-
distance_t distance_to(vertex_t target) const#
The distance of a vertex: the minimum of D(h) over the live hyperedges that contain it, 0 for the source (HD11).
- Synchronization:
Blocks until the work has completed (synchronous). Reads the vertex’s hyperedges from the hypergraph the result matches and, on cuda, the distances from the device (the stream is synchronized once per hypergraph version).
- Parameters:
target – [in] A vertex in [0, num_vertices()).
- Throws:
invalid_argument_error – if
targetis out of range, or for a moved-from result.stale_result_error – if a failed update left the result unusable (poisoned), or the hypergraph the result matches no longer exists or has changed since.
- Returns:
The distance; infinite_distance<distance_t>() if no live hyperedge of
targetis reachable (or it is in none).
-
array_view<const distance_t> vertex_distances() const#
The distances of every vertex (distance_to() of each), computed on request (HD11).
- Synchronization:
Blocks until the work has completed (synchronous). As distance_to(); one pass over the incidences per hypergraph version.
- Throws:
invalid_argument_error – for a moved-from result.
out_of_memory_error – if the array cannot be allocated.
- Returns:
num_vertices() values (host memory on every backend). Valid until the next update() of this result.
-
const options &get_options() const#
The options.
- Throws:
invalid_argument_error – for a moved-from result.
stale_result_error – if a failed update left the result unusable (poisoned).
- Returns:
The options given at compute(), as changed by set_options().
-
void set_options(const options &opt)#
Change the tunables (every field of options); the next update() uses them.
- Exception safety:
Strong: every check runs before the options change.
- Parameters:
opt – [in] The new options.
- Throws:
invalid_argument_error – if a field holds an invalid value (work_budget negative or NaN, max_iterations below 1, an enumerator out of range), or for a moved-from result.
stale_result_error – if a failed update left the result unusable (poisoned).
-
std::uint64_t graph_version() const noexcept#
The hypergraph version this result matches.
-
memory_space space() const noexcept#
The memory space of hyperedge_distances() and hyperedge_parents().
- Returns:
memory_space::device for a result of the cuda backend, memory_space::host otherwise.
-
result clone(const resources &res) const#
A deep copy (arrays, options, version, the engine’s state) for the resources
res.The copy belongs to the backend of
res(its arrays are copied between host and device memory as needed): this is how a result moves between sequential and cuda, with its hypergraph (hypergraph::to_backend()). The copy matches the moved hypergraph at once (update() accepts it), but distance_to() and vertex_distances() keep reading the hypergraph this result matches until the copy’s first update(), which links the copy to the hypergraph it is given: once that hypergraph is destroyed or changed they throw stale_result_error, so update the copy on the moved hypergraph first (an empty batch is enough) when the original may go.- Synchronization:
Blocks until the work has completed (synchronous).
- Parameters:
res – [in] Execution resources of the copy (sequential or cuda).
- Throws:
invalid_argument_error – for a moved-from result.
stale_result_error – if a failed update left the result unusable (poisoned).
not_supported_error – if the backend of
resis openmp or not built.out_of_memory_error – if the copy cannot be allocated.
cuda_error – if the CUDA runtime reports an error.
- Returns:
The copy.