Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/bipartite-matching
Maximum bipartite matching in an unweighted graph
https://github.com/mikolalysenko/bipartite-matching
Last synced: about 2 months ago
JSON representation
Maximum bipartite matching in an unweighted graph
- Host: GitHub
- URL: https://github.com/mikolalysenko/bipartite-matching
- Owner: mikolalysenko
- License: mit
- Created: 2014-01-23T22:54:59.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-29T00:48:14.000Z (over 10 years ago)
- Last Synced: 2024-10-20T14:27:57.458Z (2 months ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 13
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bipartite-matching
==================
Finds a [maximum bipartite matching](http://en.wikipedia.org/wiki/Matching_\(graph_theory\)#In_unweighted_bipartite_graphs) in an unweighted graph. The current implementation uses the [Hopcroft-Karp algorithm](http://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm) and runs in O(sqrt(V) * E + V) time. Works in both node.js and in a browser.## Example
```javascript
var findMatching = require("bipartite-matching")console.log(findMatching(5, 5, [
[0, 0],
[0, 1],
[1, 0],
[2, 1],
[2, 2],
[3, 2],
[3, 3],
[3, 4],
[4, 4]
]))
```## Install
```
npm install bipartite-matching
```## `require("bipartite-matching")(n, m, edges)`
Computes a bipartite matching for the graph* `n` is the number of vertices in the first component
* `m` is the number of vertices in the second component
* `edges` is the list of edges, represented by pairs of integers between 0 and n-1,m-1 respectively.**Returns** A list of edges representing the matching
## Credits
(c) 2014 Mikola Lysenko. MIT License