Repository navigation
Accept reordered neighbors in C graph clones - #376
Merged
Merged
Conversation
2 tasks done
jserv
reviewed
Oct 21, 2026
The graph contract ignores neighbor order, but C results depended on it and rejected valid deep copies. Normalize neighbor IDs so equivalent graphs receive the same verdict while retaining deep-copy validation.
Incomplete graph clones can leave NULL neighbor slots and crash the harness. Reject them during traversal so malformed answers receive a diagnostic and the remaining test cases can still run.
jiawei110
force-pushed
the
fix-c-graph-neighbour-order
branch
from
October 21, 2026 16:58
b18fcaf to
faa7c10
Compare
Contributor
|
Thank @jiawei110 for contributing! |
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.
Correct C graph clones could fail exact comparison when their neighbor arrays used a different order from the expected adjacency list. The C serializer now sorts temporary copies of neighbor IDs, preserving the candidate's graph and the original-node rejection check.
The regression tests cover original, reversed, partially reversed and rotated neighbor orders, including a node with three neighbors. They also compile and run a solution that returns the input graph and require rejection of every nonempty case.
Validation on Windows 11, over 4faffce:
node --test --test-name-pattern="C Clone Graph" tests/browser/compiler-explorer.test.js: 5 passed, 0 failed and 0 skipped on Windows using localcc, as confirmed by the contributor's output. This covers original, reversed, partially reversed and rotated neighbor orders, plus rejection of the original graph.git diff --checkpasses.Additional local checks run by the contributor:
npx prettier --check web/compiler-explorer.js tests/browser/compiler-explorer.test.jsnpx eslint web/compiler-explorer.js tests/browser/compiler-explorer.test.js./scripts/test.sh./scripts/test.shis not green on this Windows machine. Failing gate touch non of these filesSummary by cubic
Fixes the C Clone Graph judge rejecting valid deep copies when neighbor order differs, and now also rejects NULL neighbors in C and C++ graph clones so malformed answers get a diagnostic instead of crashing the harness.
The C serializer now sorts neighbor IDs before comparison, and both C and C++ graph serializers detect and reject NULL neighbors during traversal.
Tests:
Written for commit faa7c10. Summary will update on new commits.
Updated 20261022
Correct C graph clones could fail exact comparison when their neighbor arrays used a different order from the expected adjacency list. The C serializer now sorts temporary copies of neighbor IDs, preserving the candidate's graph and the original-node rejection check.
Both C and C++ graph serializers now reject NULL neighbor slots during traversal, before dereferencing them or generating adjacency rows. An incomplete clone receives a per-case diagnostic while subsequent cases continue to run.
The native regression tests cover original, reversed, partially reversed and rotated C neighbor orders, reversed C++ neighbors, and a node with three neighbors. They also reject returned original C nodes and exercise NULL slots on both root and reachable non-root nodes in C and C++.
Validation:
node --test --test-timeout=30000 --test-name-pattern="Clone Graph" tests/browser/compiler-explorer.test.js: 10 passed, 0 failed and 0 skipped on Windows using localccandg++../scripts/test.sh browser: 1,022 passed, 0 failed and 320 skipped because Chromium or Java was unavailable; the lane exited successfully.git diff --checkpasses.Closes #360