Skip to content

Commit 6f84ace

Browse files
✨ feat: Settle on API.
1 parent e0ad468 commit 6f84ace

23 files changed

+189
-42
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
[@aureooms/js-maximum-matching](https://aureooms.github.io/js-maximum-matching)
1+
:cherry_blossom: [@aureooms/js-maximum-matching](https://aureooms.github.io/js-maximum-matching)
22
==
33

4-
Graphs and networks code bricks for JavaScript.
5-
Parents are
6-
[@aureooms/js-algorithms](https://github.com/aureooms/js-algorithms)
7-
and
8-
[@aureooms/js-data-structures](https://github.com/aureooms/js-data-structures).
4+
Maximum matching algorithms for JavaScript.
5+
Parent is [@aureooms/js-gn](https://github.com/aureooms/js-gn).
6+
See [docs](https://aureooms.github.io/js-maximum-matching/index.html).
7+
8+
```js
9+
import maximumMatching, {iter} from '@aureooms/js-maximum-matching';
10+
const edges = [[1, 2, 10], [2, 3, 11]] ;
11+
const matching = maximumMatching(edges) ; // [-1, -1, 3, 2]
12+
iter(matching); // [ [2, 3] ]
13+
```
914

1015
[![License](https://img.shields.io/github/license/aureooms/js-maximum-matching.svg)](https://raw.githubusercontent.com/aureooms/js-maximum-matching/master/LICENSE)
1116
[![Version](https://img.shields.io/npm/v/@aureooms/js-maximum-matching.svg)](https://www.npmjs.org/package/@aureooms/js-maximum-matching)

src/cardinality/approx/bipartite.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import general from './general';
2+
3+
export default general;

src/cardinality/approx/general.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import general from '../opt/general';
2+
3+
const generalApprox = (edges, _eps) => general(edges);
4+
export default generalApprox;

src/cardinality/approx/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import bipartite from './bipartite';
2+
import general from './general';
3+
4+
export default general;
5+
6+
export {bipartite, general};

src/cardinality/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import approx from './approx';
2+
import opt from './opt';
3+
4+
export default opt;
5+
6+
export {approx, opt};

src/cardinality/opt/bipartite.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import general from './general';
2+
3+
export default general;

src/cardinality/opt/general.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import blossomNoChecks from '../../core/blossomNoChecks';
2+
3+
const general = (edges) => blossomNoChecks(edges, true);
4+
5+
export default general;

src/cardinality/opt/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import bipartite from './bipartite';
2+
import general from './general';
3+
4+
export default general;
5+
6+
export {bipartite, general};

src/exact/blossom.js renamed to src/core/blossom.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
3232
// Check optimality of solution before returning; only works on integer weights.
3333
if (CHECK_OPTIMUM === undefined) CHECK_OPTIMUM = true;
3434

35-
const maxWeightMatching = function (edges, maxcardinality) {
35+
const maxWeightMatching = function (edges, maxcardinality = false) {
3636
let i;
3737
let j;
3838
let k;
3939
let p;
4040
let w;
4141
let length;
4242

43-
if (maxcardinality === undefined) maxcardinality = false;
44-
4543
/**
4644
*
4745
* Compute a maximum-weighted matching in the general undirected

src/core/blossomNoChecks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import blossom from './blossom';
2+
3+
const blossomNoChecks = blossom(false, false);
4+
5+
export default blossomNoChecks;

0 commit comments

Comments
 (0)