Skip to content

Add Unit Tests for Empty and Single-Node Graphs in TopologicalSort #6263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 10, 2025

Conversation

Saipatnaik-23
Copy link
Contributor

@Saipatnaik-23 Saipatnaik-23 commented Jun 6, 2025

Description

This PR adds two basic unit tests to improve the test coverage of the existing TopologicalSort implementation in com.thealgorithms.sorts.TopologicalSort.java.

What's Included:

✅ testEmptyGraph(): Ensures that an empty graph returns an empty sorted list.

✅ testSingleNode(): Verifies correct output for a graph with a single node and no edges.

Checklist

  • 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 code is formatted with clang-format -i --style=file path/to/your/file.java

let me know if improvements are needed. 😊

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.07%. Comparing base (ed4a724) to head (4447243).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6263   +/-   ##
=========================================
  Coverage     74.07%   74.07%           
  Complexity     5351     5351           
=========================================
  Files           677      677           
  Lines         18648    18648           
  Branches       3621     3621           
=========================================
  Hits          13813    13813           
  Misses         4276     4276           
  Partials        559      559           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Saipatnaik-23 Saipatnaik-23 marked this pull request as ready for review June 6, 2025 17:31
@Saipatnaik-23
Copy link
Contributor Author

Hello maintainers! This PR is ready for review — all checks are passing. Please let me know if any changes are needed. Thank you! 😊

@Saipatnaik-23 Saipatnaik-23 force-pushed the topological-sort branch 2 times, most recently from 649d814 to e79ab50 Compare June 8, 2025 07:30
@Saipatnaik-23
Copy link
Contributor Author

Hello @DenizAltunkapan Added new test cases for empty and single-node graphs in the existing src/main/java/com/thealgorithms/sorts/TopologicalSort.java . Please review. Thanks!

@Saipatnaik-23
Copy link
Contributor Author

Hello @DenizAltunkapan , I’ve reverted my changes to the pom.xml file and added two test cases for Topological Sort. All checks have passed. Please have a look and review when you get a chance. Thank you looking forward to your feedback.

@Saipatnaik-23 Saipatnaik-23 changed the title Add Topological Sort algorithm using DFS in GraphSearch Add Unit Tests for Empty and Single-Node Graphs in TopologicalSort Jun 10, 2025
Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak enabled auto-merge (squash) June 10, 2025 21:04
@siriak siriak merged commit e41c2b9 into TheAlgorithms:master Jun 10, 2025
6 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.

4 participants