Closed
Conversation
Added a Java program to check if an undirected graph is a tree using DFS and adjacency matrix. Verifies connectivity and absence of cycles.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6318 +/- ##
============================================
- Coverage 74.17% 74.03% -0.15%
Complexity 5362 5362
============================================
Files 678 679 +1
Lines 18686 18719 +33
Branches 3625 3636 +11
============================================
- Hits 13860 13858 -2
- Misses 4272 4306 +34
- Partials 554 555 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
siriak
reviewed
Jun 28, 2025
|
|
||
| <description> | ||
| Avoid using the main method. | ||
| Custom PMD checks for TheAlgorithms/Java |
Member
There was a problem hiding this comment.
Please revert changes to configuration files and make sure your code passes checks and there are JUnit tests
Member
|
@amankumar100 are you still working on it? |
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.
Add Graph Tree Check using DFS and Adjacency Matrix
This PR adds a Java implementation to check whether a given undirected graph is a tree. It uses an adjacency matrix as input and applies Depth-First Search (DFS) to:
Key Points:
Input: number of nodes and adjacency matrix (1 → edge exists, 0 → no edge)
No self-loops allowed
Graph is a tree if:
No cycles exist
All nodes are reachable (i.e., graph is connected)
DSA Concept:
This problem falls under Graph Algorithms and uses DFS traversal for verification.
clang-format -i --style=file path/to/your/file.java