@@ -31,6 +31,26 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
31
31
// Check optimality of solution before returning; only works on integer weights.
32
32
if ( CHECK_OPTIMUM === undefined ) CHECK_OPTIMUM = true ;
33
33
34
+ /**
35
+ * Compute a maximum-weighted matching in the general undirected
36
+ * weighted graph given by "edges". If "maxCardinality" is true,
37
+ * only maximum-cardinality matchings are considered as solutions.
38
+ *
39
+ * Edges is a sequence of tuples (i, j, wt) describing an undirected
40
+ * edge between vertex i and vertex j with weight wt. There is at most
41
+ * one edge between any two vertices; no vertex has an edge to itthis.
42
+ * Vertices are identified by consecutive, non-negative integers.
43
+ *
44
+ * Return a list "mate", such that mate[i] === j if vertex i is
45
+ * matched to vertex j, and mate[i] === -1 if vertex i is not matched.
46
+ *
47
+ * This function takes time O(n^3)
48
+ *
49
+ * @param {Array } edges
50
+ * @param {Boolean } maxCardinality
51
+ * @return {Array }
52
+ */
53
+
34
54
const maxWeightMatching = function ( edges , maxCardinality = false ) {
35
55
let i ;
36
56
let j ;
@@ -39,23 +59,6 @@ export default function blossom(CHECK_OPTIMUM, CHECK_DELTA) {
39
59
let w ;
40
60
let length ;
41
61
42
- /**
43
- *
44
- * Compute a maximum-weighted matching in the general undirected
45
- * weighted graph given by "edges". If "maxCardinality" is true,
46
- * only maximum-cardinality matchings are considered as solutions.
47
- *
48
- * Edges is a sequence of tuples (i, j, wt) describing an undirected
49
- * edge between vertex i and vertex j with weight wt. There is at most
50
- * one edge between any two vertices; no vertex has an edge to itthis.
51
- * Vertices are identified by consecutive, non-negative integers.
52
- *
53
- * Return a list "mate", such that mate[i] === j if vertex i is
54
- * matched to vertex j, and mate[i] === -1 if vertex i is not matched.
55
- *
56
- * This function takes time O(n ** 3){
57
- */
58
-
59
62
//
60
63
// Vertices are numbered 0 .. (nvertex-1).
61
64
// Non-trivial blossoms are numbered nvertex .. (2*nvertex-1)
0 commit comments