-
Notifications
You must be signed in to change notification settings - Fork 20.5k
feat: Add Hierholzer's Algorithm for Eulerian Circuits #6726
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
base: master
Are you sure you want to change the base?
feat: Add Hierholzer's Algorithm for Eulerian Circuits #6726
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6726 +/- ##
============================================
+ Coverage 76.80% 77.33% +0.52%
- Complexity 6047 6189 +142
============================================
Files 719 722 +3
Lines 20342 20653 +311
Branches 3940 4010 +70
============================================
+ Hits 15624 15971 +347
+ Misses 4127 4060 -67
- Partials 591 622 +31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cc180be
to
568913c
Compare
d24cf14
to
96bd4fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sairamsharan Thank you for your contribution. Please remove ChatGPT-like "FINAL FIX" comments.
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.Stack; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add proper JavaDoc comments explaining this algorithm, its purpose, and expected input (e.g., undirected graph), similar to other classes in the repository.
|
||
private final Map<Integer, LinkedList<Integer>> graph; | ||
|
||
public HierholzerAlgorithm(Map<Integer, LinkedList<Integer>> graph) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider mentioning in JavaDoc that an undirected graph is expected, if it is so.
tempGraph.get(nextVertex).remove(Integer.valueOf(currentVertex)); | ||
currentPath.push(nextVertex); | ||
} else { | ||
circuit.add(0, currentPath.pop()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using LinkedList.addFirst() for better performance.
|
||
dfs(startNode, visited); | ||
|
||
// FINAL FIX: Use entrySet for efficiency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "FINAL FIX:" ? I think this comment might be confusing...
List<Integer> circuit = new LinkedList<>(); | ||
|
||
int startVertex = -1; | ||
// FINAL FIX: Use entrySet for efficiency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "FINAL FIX:" ? I think this comment might be confusing...
clang-format -i --style=file path/to/your/file.java