-
-
Notifications
You must be signed in to change notification settings - Fork 342
Hopcroft karp max matching #269
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?
Hopcroft karp max matching #269
Conversation
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.
Pull Request Overview
This pull request introduces a substantial collection of algorithms and data structures to the R repository, primarily focused on graph algorithms, dynamic programming, and machine learning implementations. The PR appears to be part of expanding TheAlgorithms/R with comprehensive algorithmic implementations.
Key changes:
- Addition of 10+ graph algorithms including Hopcroft-Karp, Dijkstra, Floyd-Warshall, and various MST algorithms
- Implementation of 6+ dynamic programming solutions covering classic problems like knapsack, LCS, and coin change
- Addition of mathematics algorithms including bisection method and Armstrong number checking
- Inclusion of machine learning implementations (gradient boosting) and documentation files
Reviewed Changes
Copilot reviewed 138 out of 214 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| graph_algorithms/hopcroft_karp_max_matching.r | Implements Hopcroft-Karp algorithm for maximum bipartite matching |
| graph_algorithms/dijkstra_shortest_path.r | Dijkstra's algorithm with priority queue implementation |
| graph_algorithms/floyd_warshall.r | All-pairs shortest path algorithm with R6 class structure |
| dynamic_programming/subset_sum.r | Subset sum problem with both standard and optimized solutions |
| dynamic_programming/longest_increasing_subsequence.r | LIS algorithm with O(n²) and O(n log n) variants |
| machine_learning/gradient_boosting.r | Complete gradient boosting regressor implementation |
| mathematics/bisection_method.r | Root-finding algorithm implementation |
| mathematics/armstrong_number.r | Armstrong number checking function |
|
You have changed 214 files, check your changes |
Algorithm: Hopcroft-Karp
Purpose: Computes the maximum matching in a bipartite graph, i.e., the largest set of edges where no two edges share a vertex.
Theory:
Uses the concept of augmenting paths: a path that alternates between unmatched and matched edges, starting and ending at unmatched vertices.
By finding shortest augmenting paths and augmenting along multiple disjoint paths in one phase, it minimizes the number of iterations.
Relies on BFS to layer the graph and find distances to unmatched vertices, and DFS to actually augment paths.
Efficiency: Faster than naive augmenting path algorithms because it increases matching size by multiple paths per iteration.
Time Complexity: O(E × √V)
Space Complexity: O(V + E)
Input: Bipartite graph as an adjacency list from the left partition to the right partition.
Output: Maximum matching size and the matched vertex pairs.