Repository navigation
[R45-T018] Cover failure and empty-result paths of HierholzerAlgorithm - #58
Open
shyamlibakale1001-alt wants to merge 1 commit into
Open
shyamlibakale1001-alt wants to merge 1 commit into
shyamlibakale1001-alt wants to merge 1 commit into
Conversation
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.
Description
Documents the failure and absent-result paths on
hasEulerianCircuit()andfindEulerianCircuit()insrc/main/java/com/thealgorithms/graph/HierholzerAlgorithm.java, adds JUnit failure-path regression tests (HierholzerAlgorithmFailureTest.java), and adds a focused runner (work/R45-T018/check.py). Existing supported behavior, caller-owned graph preservation, and the public interface are preserved.Related Issue
Fixes: #18
Type of Change
Changes Made
hasEulerianCircuit()(lines 41–48) andfindEulerianCircuit()(lines 63–72) insrc/main/java/com/thealgorithms/graph/HierholzerAlgorithm.javaexplaining the empty/absent-result paths (Collections.emptyList()on odd degree, disconnected non-zero-degree components, or empty/nullgraph, and single-element list for isolated degree-0 vertices). No executable code or public API was modified.src/test/java/com/thealgorithms/graph/HierholzerAlgorithmFailureTest.javawith 3 test methods (7 logged cases):nullgraph, empty{}graph ([]), and smallest isolated vertex{0=[]}([0]).{0=[1], 1=[0]}reaching line 56falseand line 75Collections.emptyList()), verifying caller-ownedgraphstays unmutated and an ordinary valid triangle ([0, 1, 2, 0]) succeeds afterwards (including repeated calls).falseand line 75Collections.emptyList()), verifying caller-ownedgraphstays unmutated and a subsequent ordinary valid call succeeds.work/R45-T018/check.py(with evidence files inwork/R45-T018/), runningmvn testforHierholzerAlgorithmFailureTest, enforcing a nonzero test count, savingcomparisons.txt,result.txt,mvn_output.txt, andtool_versions.txt, and exiting non-zero on failure.Screenshots / Recordings
Not applicable (no UI changes).
Testing
Command:
python3 work/R45-T018/check.py(runs
mvn -B test -Dtest=HierholzerAlgorithmFailureTest -Dsurefire.failIfNoSpecifiedTests=false)Result:
tests=3 failures/errors=0 skipped=0 records=7 mvn_exit=0,status=PASSExisting suite:
mvn -B test -Dtest=HierholzerAlgorithmTest -Dsurefire.failIfNoSpecifiedTests=false→Tests run: 4, Failures: 0, Errors: 0, Skipped: 0(BUILD SUCCESS).Negative check: temporarily disabling the odd-degree check on line 55 (
if (neighbors.size() % 2 != 0)→if (neighbors.size() < 0)) causedpython3 work/R45-T018/check.pyto printstatus=FAIL(tests=3 failures/errors=1 skipped=0 mvn_exit=1) and exit non-zero; reverted and re-verified.Style:
mvn -B checkstyle:checkreports0 Checkstyle violations(BUILD SUCCESS).Tool versions and check records are saved in
work/R45-T018/tool_versions.txtandwork/R45-T018/comparisons.txt.Checklist
Additional Notes
No error-handling repair was needed because
HierholzerAlgorithmalready returnsCollections.emptyList()without mutating caller-owned adjacency lists (tempGraphcopies them on lines 78–81).The
work/R45-T018/evidence folder is for coursework review only and should not go into any later upstream PR.I have read CONTRIBUTING.md.
This pull request is all my own work -- I have not plagiarized it.
All filenames are in PascalCase.
All functions and variable names follow Java naming conventions.
All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
All new algorithms include a corresponding test class that validates their functionality.
All new code is formatted with
clang-format -i --style=file path/to/your/file.java