-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Implemented Edmonds Blossom Algorithm #5471
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
Conversation
…graphs with test cases and improved output formatting.
…a/com/thealgorithms/datastructures/graphs
# Conflicts: # DIRECTORY.md
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5471 +/- ##
============================================
+ Coverage 52.31% 52.58% +0.27%
- Complexity 3259 3285 +26
============================================
Files 526 527 +1
Lines 15205 15312 +107
Branches 2892 2913 +21
============================================
+ Hits 7954 8052 +98
- Misses 6924 6929 +5
- Partials 327 331 +4 ☔ View full report in Codecov by Sentry. |
I apologize for so many file changes but there were too many issue to fix one by one. Thankfully it all works now. 😄 Thank you for understanding😄😄. |
src/main/java/com/thealgorithms/datastructures/graphs/EdmondsBlossomAlgorithm.java
Outdated
Show resolved
Hide resolved
src/main/java/com/thealgorithms/datastructures/graphs/EdmondsBlossomAlgorithm.java
Outdated
Show resolved
Hide resolved
Sure will do |
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.
Removed the method. Test cases are in JUnit Tests
src/main/java/com/thealgorithms/datastructures/graphs/EdmondsBlossomAlgorithm.java
Outdated
Show resolved
Hide resolved
src/main/java/com/thealgorithms/datastructures/graphs/EdmondsBlossomAlgorithm.java
Outdated
Show resolved
Hide resolved
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.
Looks good, thanks!
Please add Hacktober fest lable to this PR. |
Hey I've implemented Edmond's Blossom Algorithm in src/main/java/com.thealgorithms/datastructures/graphs/EdmondBlossomAlgorithm.java
with the test class in the test package
for enhancement #5470
This PR implements the Edmonds Blossom Algorithm, a well-known algorithm used to find maximum matchings in general graphs, including non-bipartite graphs. The algorithm is crucial in combinatorial optimization and graph theory.
Key Features:
Handles odd-length cycles (blossoms) by contracting them into single nodes, which allows the matching process to proceed in general graphs.
Finds the maximum cardinality matching in polynomial time.
Works efficiently for both directed and undirected graphs.
Algorithm Overview:
Initialization: Start with an empty matching and process the graph.
Augmenting Path Search: Search for augmenting paths using alternating paths (paths alternating between matched and unmatched edges).
Blossom Contraction: When an odd-length cycle (blossom) is encountered, it is temporarily contracted into a single node.
Expansion and Matching Update: Once an augmenting path is found, the blossoms are expanded, and the matching is updated.
Performance:
The time complexity is O(V^3), where V is the number of vertices in the graph.
This algorithm is especially useful in various applications such as network flow problems, stable marriages, and graph partitioning.
clang-format -i --style=file path/to/your/file.java