Skip to content

fix(dijkstra): fix visitor semantics, comparator consistency, and neg…#25

Merged
pratzl merged 2 commits intomainfrom
dijkstra
Apr 26, 2026
Merged

fix(dijkstra): fix visitor semantics, comparator consistency, and neg…#25
pratzl merged 2 commits intomainfrom
dijkstra

Conversation

@pratzl
Copy link
Copy Markdown
Collaborator

@pratzl pratzl commented Apr 26, 2026

…ative-weight check

  • Add stale-pop skip to ensure on_examine_vertex/on_finish_vertex fire exactly once per vertex, matching BGL visitor semantics so user-supplied Compare is used consistently (matches BGL)
  • Replace is_signed_v + '<' negative-weight guard with compare(w, zero) so any user-defined ordering is respected (matches BGL)
  • Remove spurious logic_error when an edge to an undiscovered vertex is not relaxed; this assumption breaks with custom Compare/Combine that saturate at the infinity sentinel
  • Update the stale-entry comment to reflect corrected semantics
  • Add note near priority_queue pointing to indexed_dary_heap_plan.md
  • Update test: 'infinite weight edge triggers logic_error' is now 'infinite weight edge leaves vertex unreachable' (no throw expected)
  • Add agents/indexed_dary_heap_plan.md: phased plan for replacing std::priority_queue with an indexed d-ary heap (decrease-key)

pratzl added 2 commits April 25, 2026 21:35
…ative-weight check

- Add stale-pop skip to ensure on_examine_vertex/on_finish_vertex fire
  exactly once per vertex, matching BGL visitor semantics
  so user-supplied Compare is used consistently (matches BGL)
- Replace is_signed_v + '<' negative-weight guard with compare(w, zero)
  so any user-defined ordering is respected (matches BGL)
- Remove spurious logic_error when an edge to an undiscovered vertex is
  not relaxed; this assumption breaks with custom Compare/Combine that
  saturate at the infinity sentinel
- Update the stale-entry comment to reflect corrected semantics
- Add note near priority_queue pointing to indexed_dary_heap_plan.md
- Update test: 'infinite weight edge triggers logic_error' is now
  'infinite weight edge leaves vertex unreachable' (no throw expected)
- Add agents/indexed_dary_heap_plan.md: phased plan for replacing
  std::priority_queue with an indexed d-ary heap (decrease-key)
…ht types

The runtime compare(w, zero) check is compiled out entirely when weight_type
is an unsigned integral type, since no such value can be negative. For all
other types (signed, floating-point, user-defined) the comparator-based check
still runs, preserving correctness.
@pratzl pratzl merged commit 65d6018 into main Apr 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant