fix issue with maximum-bipartite-matching/stable
This commit is contained in:
parent
16a6abf9b5
commit
98db7e9dce
|
@ -44,7 +44,9 @@
|
||||||
(define num-first-lefts
|
(define num-first-lefts
|
||||||
(for/sum ([m (in-list matching)] #:when (set-member? left (first m)))
|
(for/sum ([m (in-list matching)] #:when (set-member? left (first m)))
|
||||||
1))
|
1))
|
||||||
(if (> num-first-lefts (/ (set-count left) 2))
|
;; if the first set contains more elements belonging to lefts than rights, then assume it's in
|
||||||
|
;; the right order. otherwise, swap
|
||||||
|
(if (> num-first-lefts (- (length matching) num-first-lefts))
|
||||||
matching
|
matching
|
||||||
(map #{list (second %) (first %)} matching)))
|
(map #{list (second %) (first %)} matching)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue