Skip to content

Conversation

the-yash-rajput
Copy link
Contributor

@the-yash-rajput the-yash-rajput commented Oct 1, 2025

  • 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

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2025

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.22%. Comparing base (421ac6d) to head (88f2467).

Files with missing lines Patch % Lines
.../java/com/thealgorithms/graph/TopologicalSort.java 94.73% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6568      +/-   ##
============================================
+ Coverage     75.19%   75.22%   +0.03%     
- Complexity     5614     5625      +11     
============================================
  Files           690      691       +1     
  Lines         19407    19445      +38     
  Branches       3755     3763       +8     
============================================
+ Hits          14593    14628      +35     
- Misses         4247     4250       +3     
  Partials        567      567              

☔ 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.

@alxkm
Copy link
Member

alxkm commented Oct 1, 2025

Looks like this is already in the repository, but in the wrong package it is definitely related to the graph

https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/sorts/TopologicalSort.java

@the-yash-rajput
Copy link
Contributor Author

the-yash-rajput commented Oct 1, 2025

@alxkm How would you like to proceed?
Should we merge this PR or replace the previous implementation with the correct location?

@alxkm I think we can include both, as the previous algorithm is not more friendly to graphs.

@alxkm
Copy link
Member

alxkm commented Oct 1, 2025

@siriak, @DenizAltunkapan, Could you please help clarify our approach here?

There are already several implementations of this algorithm in the repository:

The previous implementation follows a more traditional pattern as it operates directly on color values.
The current implementation also good and it has test coverage.

From my perspective, the optimal solution would be to:

  • Migrate the old implementation here
  • Make it generic
  • Clean up the code (e.g., implement specialized exceptions which already presented here)
  • Maintain test suites for both variants

What are your thoughts on this approach?

@the-yash-rajput
Copy link
Contributor Author

@alxkm Let’s first align on the right strategy and once confirmed, we can proceed with the necessary implementation.

@alxkm
Copy link
Member

alxkm commented Oct 3, 2025

@the-yash-rajput, you can proceed with the following approach as I described - creating a generic implementation of the algorithm.

  • Migrate the existing implementation to the correct package location
  • Refactor it to be generic and reusable
  • Implement the specialized exceptions that are already present in the your version
  • And generic tests for it with Integer and String values

This approach will provide the traditional algorithm that uses color values.

What do you think about this?

@siriak
Copy link
Member

siriak commented Oct 3, 2025

@alxkm I agree with the proposed approach, I think both implementations should be stored together.

P.S. I reviewed this 2 days ago, but forgot to write a reply and then lost the tab -_-

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