Skip to content

Shyamli Bakale — R45-T014: Test an invariant of BipartiteGraphDFS (BipartiteGraphDFS.java) [src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java] #14

Open

Description

@ankushbisht01

Student: Shyamli Bakale

Task: R45-T014 · 4 of 10
Repository: https://github.com/S-AI-Projects/TheAlgorithms-Java
Assigned working branch: student/e26b07f0813

Goal

Work on src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java. Add a property test around BipartiteGraphDFS: Reachable nodes appear once in the traversal and a cycle cannot cause an infinite walk. Fixture: Use A→B, B→C, C→A and an isolated D. Start at A and check that the cycle terminates without visiting D.

Steps

  1. Read src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java, especially BipartiteGraphDFS near line 32. Record its public inputs, result, mutation behavior and any external dependencies before changing it.
  2. Use the fixture to establish the invariant on understandable examples. Use A→B, B→C, C→A and an isolated D. Start at A and check that the cycle terminates without visiting D.
  3. Generate at least 100 bounded valid cases with a fixed seed; restrict the generator to the actual input domain and retain a readable small case.
  4. Implement work/R45-T014/check.py as a focused runner that executes the new checks and propagates failures. Native check to incorporate: mvn test (JDK 21 as specified in pom.xml); use JUnit in the corresponding src/test/java package. Record the actual command and nonzero test count.
  5. Create the checks specified below and run python3 work/R45-T014/check.py. Save inputs, expected versus actual results and tool versions in work/R45-T014/; a check must exit non-zero when an assertion fails.
  6. Commit the repository change on branch R45-T014; prepare a PR to the organisation fork explaining the result and linking the checks. Keep each task independently reviewable. Remove work/R45-T014/ from a later upstream branch.

Done when

☐ The checked behavior is tied to BipartiteGraphDFS in src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java; every assertion has an explicit expected value.
☐ Use A→B, B→C, C→A and an isolated D. Start at A and check that the cycle terminates without visiting D.
☐ Existing supported behavior and the public interface are preserved unless a failing regression demonstrates and documents a defect.
☐ The generator never relies on undefined input behavior; the invariant is justified in the PR.
☐ The checks fail when the relevant invariant is deliberately broken in a temporary copy.

Additional task guidance

Additional curated task guidance

Item:
src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java

Task type:
Invariant/property checks

Code change (goes into the PR):
Add invariant-based tests for src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java, with a deterministic seed and the smallest failing example; document the invariant next to the implementation.

Automated check:
python3 work/R45-T014/check.py

Prerequisites:
JDK 21, Maven and Python 3.

Upstream PR rules:
Follow the Java style and Maven checks. The project does not accept standalone LeetCode problem additions; a new feature requires an upstream issue first. Submit coursework to the organisation fork first; keep work/ evidence out of any later upstream PR. Upstream acceptance is not a grading requirement. Policy: https://github.com/TheAlgorithms/Java/blob/6edd2d878947c7fb08a6f3286b316eca09fe9200/CONTRIBUTING.md

Source (pinned):
https://github.com/TheAlgorithms/Java/blob/6edd2d878947c7fb08a6f3286b316eca09fe9200/src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java#L32

Change:
Replaces the shared task template with an item-specific contribution brief.

PR destination:
Upstream candidate after review

Submission checklist

  • Complete this task and its checks.
  • Add the required evidence and link your pull request here.
  • Select this S-AI-Projects fork as the PR base repository.
  • Request instructor review.

Keep this PR focused on this task. Do not submit assignment PRs to the upstream repository.

Activity

  1. shyamlibakale1001-alt commented on Nov 11, 2026

    @shyamlibakale1001-alt

    Pull Request: #55

    Verification summary:

    • Branch: student/e26b07f0813/R45-T014
    • Check command: python3 work/R45-T014/check.py -> tests=3 failures/errors=0 skipped=0 records=5 mvn_exit=0, status=PASS
    • Existing tests: mvn -B test -Dtest=BipartiteGraphDFSTest -> Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
    • Style check: mvn -B checkstyle:check -> 0 Checkstyle violations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions