Skip to content

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

Merged
merged 36 commits into from
Oct 2, 2024
Merged

Implemented Edmonds Blossom Algorithm #5471

merged 36 commits into from
Oct 2, 2024

Conversation

TarunVishwakarma1
Copy link
Contributor

@TarunVishwakarma1 TarunVishwakarma1 commented Sep 25, 2024

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.

  • 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 Sep 25, 2024

Codecov Report

Attention: Patch coverage is 91.58879% with 9 lines in your changes missing coverage. Please review.

Project coverage is 52.58%. Comparing base (842ff52) to head (5e24873).

Files with missing lines Patch % Lines
...datastructures/graphs/EdmondsBlossomAlgorithm.java 91.58% 5 Missing and 4 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

@TarunVishwakarma1
Copy link
Contributor Author

I apologize for so many file changes but there were too many issue to fix one by one. Thankfully it all works now. 😄
If its in scope of merging to the repo, may I ask that you do it in October, I've signed up for the hacktoberfest and it will be great if I got a merge at that time.

Thank you for understanding😄😄.

@TarunVishwakarma1 TarunVishwakarma1 changed the title Implemented Edmonds Blossom Algorithm Implemented Edmonds Blossom Algorithm #5470 Sep 25, 2024
@TarunVishwakarma1 TarunVishwakarma1 changed the title Implemented Edmonds Blossom Algorithm #5470 Implemented Edmonds Blossom Algorithm Sep 25, 2024
@TarunVishwakarma1 TarunVishwakarma1 marked this pull request as draft September 25, 2024 16:45
@TarunVishwakarma1 TarunVishwakarma1 marked this pull request as ready for review October 1, 2024 10:45
@TarunVishwakarma1
Copy link
Contributor Author

Sure will do

Copy link
Contributor Author

@TarunVishwakarma1 TarunVishwakarma1 left a 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

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak enabled auto-merge (squash) October 2, 2024 18:01
@siriak siriak merged commit e493eb2 into TheAlgorithms:master Oct 2, 2024
5 checks passed
@TarunVishwakarma1
Copy link
Contributor Author

Please add Hacktober fest lable to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants