Python icon indicating copy to clipboard operation
Python copied to clipboard

Added edmonds_blossom_algorithm.py. For maximum matching in the graph. #12043

Open TarunVishwakarma1 opened this issue 1 year ago • 2 comments

Describe your change:

This PR implements the Edmonds' Blossom Algorithm in the EdmondsBlossomAlgorithm class, which efficiently finds the maximum matching in general graphs, including those with odd-length cycles. The implementation includes methods for handling augmenting paths, updating matchings, and contracting blossoms.

Maximum Matching: Introduces the maximumMatching method, which takes a list of edges and the total number of vertices as input and returns a list of matched pairs of vertices. Augmenting Path Search: Utilizes a breadth-first search (BFS) approach to locate augmenting paths within the graph, ensuring that it can handle complex graph structures effectively. Blossom Contraction: Implements mechanisms for contracting blossoms to manage odd-length cycles, which is a key aspect of the algorithm's efficiency. Detailed Comments: Each method and critical section of the code are thoroughly commented to ensure clarity and understanding of the algorithm's functionality.

  • [x] Add an algorithm?
  • [ ] Fix a bug or typo in an existing algorithm?
  • [ ] Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • [ ] Documentation change?

Checklist:

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized.
  • [x] I know that pull requests will not be merged if they fail the automated tests.
  • [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • [x] All new Python files are placed inside an existing directory.
  • [x] All filenames are in all lowercase characters with no spaces or dashes.
  • [x] All functions and variable names follow Python naming conventions.
  • [x] All function parameters and return values are annotated with Python type hints.
  • [x] All functions have doctests that pass the automated testing.
  • [x] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • [x] If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #12043 ".

TarunVishwakarma1 avatar Oct 14 '24 06:10 TarunVishwakarma1

The first 2 PR's were giving errors and had to re-fork the repo, So deleted the pr and created fresh new PR

TarunVishwakarma1 avatar Oct 14 '24 06:10 TarunVishwakarma1