Skip to content

Add Hopcroft-Karp algorithm and doctests for manual_accuracy function#13233

Open
G26karthik wants to merge 6 commits into
TheAlgorithms:masterfrom
G26karthik:feat/hopcroft-karp-matching
Open

Add Hopcroft-Karp algorithm and doctests for manual_accuracy function#13233
G26karthik wants to merge 6 commits into
TheAlgorithms:masterfrom
G26karthik:feat/hopcroft-karp-matching

Conversation

@G26karthik
Copy link
Copy Markdown

@G26karthik G26karthik commented Oct 5, 2025

Contributes to #9943

Description

This PR includes two contributions:

  1. Hopcroft-Karp Algorithm Implementation: Adds the Hopcroft-Karp algorithm for finding maximum matching in bipartite graphs, a fundamental graph algorithm with O(E√V) time complexity.

  2. Test Coverage Improvement: Adds comprehensive doctests to the manual_accuracy() function in machine_learning/scoring_functions.py.

Changes

New Algorithm

  • Added graphs/hopcroft_karp.py with full implementation
  • Includes detailed docstring and usage examples
  • Comprehensive doctests covering various graph scenarios

Enhanced Test Coverage

  • Added docstring with detailed function description for manual_accuracy()
  • Added 4 doctest examples covering:
    • High accuracy (80% correct predictions)
    • Perfect accuracy (100% correct)
    • Zero accuracy (completely wrong predictions)
    • Complete inverse predictions (0% accuracy)

Testing

  • All doctests pass successfully for both contributions
  • Hopcroft-Karp: Multiple test cases for bipartite matching
  • manual_accuracy: 12 doctest lines (4 examples) all passing
  • Existing tests for mae, mse, rmse, rmsle, mbd remain passing

@algorithms-keeper algorithms-keeper Bot added the tests are failing Do not merge until tests pass label Oct 6, 2025
@G26karthik G26karthik changed the title feat(graphs): Add Hopcroft-Karp maximum bipartite matching algorithm Add Hopcroft-Karp algorithm and doctests for manual_accuracy function Oct 6, 2025
@algorithms-keeper algorithms-keeper Bot removed the tests are failing Do not merge until tests pass label Oct 6, 2025
@Tarannum9623
Copy link
Copy Markdown

Tarannum9623 commented Oct 6, 2025

Hi! Can you help me by telling why my build test is failing, I want to contribute search_in_a_rotated_sorted_array in search directory and my build test failed.
PR: Search in rotated sorted array #13245

@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Oct 7, 2025
Copilot AI review requested due to automatic review settings May 28, 2026 07:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Hopcroft-Karp bipartite matching implementation and adds a docstring with doctests to the existing manual_accuracy function.

Changes:

  • New graphs/hopcroft_karp_matching.py implementing Hopcroft-Karp maximum bipartite matching with BipartiteGraph class.
  • Adds documentation and doctests for manual_accuracy in machine_learning/scoring_functions.py.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
graphs/hopcroft_karp_matching.py New module implementing Hopcroft-Karp algorithm with BFS/DFS phases and doctests.
machine_learning/scoring_functions.py Adds docstring with examples for manual_accuracy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread graphs/hopcroft_karp_matching.py
Comment thread graphs/hopcroft_karp_matching.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants