explainable-predicates-0.1.2.3: Predicates that can explain themselves.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Predicates.Internal.FlowMatcher

Description

An implementation of bipartite matching using the Ford-Fulkerson algorithm.

Synopsis

Documentation

>>> :set -Wno-type-defaults

bipartiteMatching :: forall a b. (a -> b -> Bool) -> [a] -> [b] -> ([(a, b)], [a], [b]) Source #

Computes the best bipartite matching of the elements in the two lists, given the compatibility function.

Returns matched pairs, then unmatched lhs elements, then unmatched rhs elements.

>>> bipartiteMatching (==) [1 .. 5] [6, 5 .. 2]
([(2,2),(3,3),(4,4),(5,5)],[1],[6])