Fix DirectedHamiltonianVerifier missing closing-edge check - #507
Open
Trosper3 wants to merge 1 commit into
Open
Conversation
The verifier checked consecutive edges in a certificate but never required the walk to close back to its starting vertex, and had an off-by-one in its coverage check that happened to mask the gap for exact-length certificates. Ports the closure fix already applied to the undirected HamiltonianVerifier in b719fda, adapted for directed edges (no reverse-edge fallback), and removes an unused pairCheck2 left over from that copy.
Redux Build System — CI Report
Overall: ❌ 4 passed · 1 failed · 3 skipped |
2 tasks
Trosper3
added a commit
that referenced
this pull request
Sep 1, 2026
Superseded by the fix+test file already open in PR #507 (fixes the missing closing-edge check and adds fuller test coverage vs. this PR's 3-test format smoke check). Keeping the instanceFormat/certificateFormat declaration changes; only dropping the file that would otherwise collide on merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DirectedHamiltonianVerifierchecked consecutive edges in a certificate but never required the walk to close back to its starting vertex — the loop wasfor (i = 0; i < order.Count - 1; i++), so the last listed node's closing edge back to the start was never checked. An off-by-one in the coverage check happened to mask this for exact-length certificates, but an (n+1)-length certificate that visits every node via valid edges without ever returning to the start was incorrectly accepted.HamiltonianVerifieralready had this exact bug fixed inb719fda("Fix TSP and Hamiltonian verifiers missing closing-edge check") — only the directed verifier still had the hole, so this PR ports that same fix, adapted for directed edges (no reverse-edge fallback, since direction matters here).pairCheck2variable left over from copying the undirected verifier (issue's "Bug 3").Closes #255
Test plan
dotnet test --filter "...DIRECTEDHAMILTONIAN_Tests"— 8/8 passed (new test file; no prior tests existed for this problem)dotnet build --configuration Release(gates ondotnet format --verify-no-changes) — cleandotnet test(full suite) — 906/906 passed