-
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 77.82% 77.81% -0.01%
- Complexity 6392 6410 +18
============================================
Files 732 733 +1
Lines 21320 21384 +64
Branches 4182 4200 +18
============================================
+ Hits 16592 16641 +49
- Misses 4059 4064 +5
- Partials 669 679 +10 ☔ 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