A Faster Maximum Cardinality Matching Algorithm with Applications in Machine Learning

1 Introduction . Computing a maximum cardinality matching is a fundamental graph optimization problem . With origins in economics and logistics , matchings have found numerous applications . Computing popular distances between distributions , such as the Wasserstein distance as well as the Lévy-Prokhorov distance , can be reduced to a bipartite matching problem . In this paper , we consider the δ-disc graph matching which is the following : Given two sets A and B of n two dimensional points and a parameter δ > 0 , a δ-disc graph Gδ is a bipartite graph obtained by connecting any pair of vertices ( a , b ) ∈ A×B with an edge provided that the Euclidean distance between a and b is at most δ , i.e. , ‖a− b‖ ≤ δ . Let m be the number of edges ∗Authors are ordered by last name . All authors contributed equally to this work . 2We use Õ ( · ) to suppress poly-logarithmic terms in the complexity . 35th Conference on Neural Information Processing Systems ( NeurIPS 2021 ) . in the graph Gδ . A matching M is a set of vertex-disjoint edges in Gδ . In the δ-disc graph matching problem , we wish to compute a maximum cardinality matching in Gδ , i.e. , a matching that has the largest number of edges . Any algorithm for computing a δ-disc graph matching can also be used to compute a bottleneck matching as well as the Lévy-Prokhorov distance , both of which are defined next . Let M ⊆ A×B be any perfect matching of A and B , which is a matching where every vertex of A is matched , i.e. , |M | = n. The edge of M with the largest Euclidean length is its bottleneck edge . The bottleneck matching is a perfect matching M∗ whose bottleneck edge length is minimized . The Euclidean length of the bottleneck edge of M∗ is the bottleneck distance between A and B. Distances between distributions : Next , consider the case where A and B define discrete distributions PA and PB and let every point a ∈ A ( resp . b ∈ B ) carry a probability of 1/n , i.e. , PA ( a ) = 1/n ( resp . PB ( b ) = 1/n ) . The ∞-Wasserstein distance between PA and PB , denoted by W∞ ( PA , PB ) , is simply the bottleneck distance between the point sets A and B . The Lévy-Prokhorov distance between PA and PB is defined as follows : For ε > 0 and any subset X ⊆ A ( resp . Y ⊆ B ) , let Xε = { b ∈ B | ∃a ∈ X such that ‖a − b‖ ≤ ε } ( resp . Y ε = { a ∈ A | ∃b ∈ Y such that ‖a − b‖ ≤ ε } ) . Note that Xε ⊆ B and Y ε ⊆ A . We say that the Lévy-Prokhorov [ 34 ] distance π ( PA , PB ) is equal to the smallest value of ε for which the following property is true : ∀X ⊆ A , PA ( X ) ≤ PB ( Xε ) + ε and , ∀Y ⊆ B , PB ( Y ) ≤ PA ( Y ε ) + ε ; here PA ( X ) = ∑ a∈X PA ( a ) = |X|/n and PB ( Y ) = ∑ b∈Y PB ( b ) = |Y |/n . We can , therefore , write this condition as ∀X ⊆ A , |X| ≤ |Xε|+ εn and ∀Y ⊆ B , |Y | ≤ |Y ε|+ εn . ( 1 ) Determining if the exact bottleneck distance ( equivalently W∞ ( PA , PB ) ) is ≤ δ can be done by simply finding the maximum cardinality matching M in Gδ . It is easy to see that M is perfect if and only if the bottleneck distance is at most δ . Similarly , by applying Hall ’ s theorem , one can show that π ( PA , PB ) ≤ ε if and only if the maximum cardinality matching M in Gε has a size of at least ( 1− ε ) n. Thus , the δ-disc graph matching directly relates to computing∞-Wasserstein distance as well as the Lévy-Prokhorov distance between probability distributions . Computing δ-disc graph matching : One can use any of-the-shelf matching algorithm [ 18 , 31 , 33 , 39 ] to compute a maximum cardinality matching in a δ-disc graph . For instance , using the well-known Hopcroft-Karp algorithm will lead to an execution time of O ( m √ n ) on any δ-disc graph . The HK-Algorithm executes in phases . Each phase takes O ( m ) time , and , in the worst-case , the algorithm converges to a maximum matching in O ( √ n ) phases . The best-known exact algorithm for computing the exact bottleneck matching combines geometric data structures with the HK-algorithm in order to reduce the execution time of each phase from O ( m ) to Õ ( n ) . As a result , they obtain an exact bottleneck matching in Õ ( n3/2 ) time . Inspired by a series of algorithms for weighted matching in graphs with small separators [ 4 , 27 ] , Lahn and Raghvendra [ 28 ] presented a weighted approach to the maximum cardinality matching problem . This LR algorithm identifies a set of “ edge separators '' incident on ω “ boundary vertices ” . These edges are assigned a weight of 1 and all other edges receive a weight of 0 . A property satisfied by these separator vertices is that after their removal , every connected component in the graph has no more than r vertices . Then , they present an algorithm to compute a perfect matching in O ( m √ r + m √ ω + mrω/n log n ) time . As an application of their result , they show how to compute the bottleneck distance of any point sets A and B within a multiplicative factor of ( 1 + ε ) in Õ ( n4/3poly ( 1/ε ) ) time . The LR algorithm assigns dual weights to vertices and is similar in style to the Kuhn-Munkres [ 24 ] and Gabow-Tarjan [ 15 ] algorithms . The dual weights on vertices play a vital role in the proofs of correctness and efficiency of the LR algorithm . In this paper , we make the following contributions : • We remove the need to maintain dual weights in the LR algorithm , resulting in a significantly simpler algorithm . • Using this algorithm , we show how to find a maximum cardinality matching in a unit-disc graphGδ in time Õ ( n4/3k1/3 ) where k is the maximum number of points ofA∪B contained in any disc of radius δ . Note that our algorithm is asymptotically faster than the classical Hopcroft-Karp based algorithm when k = o ( √ n ) . • Using our algorithm for δ-disc graph matching , we show how to compute the exact bottleneck distance between point sets A and B . When PA and PB are discrete distributions with each point having probability 1/n , the bottleneck distance can be used to compute the distances W∞ ( PA , PB ) ) and π ( PA , PB ) . We are not aware of any previous polynomial time algorithms to compute the Lévy-Prokhorov distance . When A , B are chosen uniformly at random from a unit square , our algorithm for the exact bottleneck distance runs in Õ ( n4/3 ) time . All previous algorithms take Ω ( n3/2 ) time . • We run experiments for the case where A and B are chosen uniformly at random from a unit square . Our experiments suggest that the Hopcroft-Karp algorithm on Gδ takes Θ ( n3/2 ) time . In contrast , our algorithm runs substantially faster and executes in Õ ( n4/3 ) time . Note that , for the HK-algorithm , the upper bound of O ( √ n ) phases is only in the worst-case . As noted by Motwani [ 32 ] , the Hopcroft-Karp algorithm converges , with high probability , to a maximum matching in O ( log n ) phases for expander graphs in general and Erdős-Rényi random graphs in particular . Similarly , does the HK algorithm execute asymptotically fewer than √ n iterations when used to compute bottleneck matchings ? Interestingly , our experiments suggest that the answer to this question may be in the negative . Based on our experimental results , when A and B are drawn uniformly at random from a unit square and when δ is set to the bottleneck distance , the number of phases seem to grow at the rate of Ω ( √ n ) . Therefore , bottleneck matching on random point sets may represent a natural hard instance for the HK-Algorithm . In this paper , we show how to overcome the Ω ( n3/2 ) barrier for uniformly distributed point sets by developing an Õ ( n4/3 ) time algorithm . For any ε > 0 and any point set A∪B , the LR algorithm can also be used to compute a multiplicative ( 1 + ε ) -approximation of the bottleneck matching in Õ ( n4/3poly ( 1/ε ) ) time . This is done by using a grid where the side-length of each cell is a function of ε . The algorithm rounds every point to the closest cell center and finds a δ-disc graph matching using the LR algorithm . See Section 6 of [ 28 ] for details . One can also use a similar approach to compute a multiplicative ( 1 + ε ) approximation of the Lévy-Prokhorov distance . Replacing the original LR algorithm with our dual-free implementation leads to simpler approximation algorithms . Applications : Wasserstein distance has found numerous applications in machine learning and computer vision [ 3 , 5 , 8 , 10 , 14 , 36 ] . Due to these applications , computing approximations of Wasserstein distances has received substantial attention [ 2 , 9 , 12 , 26 , 30 , 35 ] . However , exact algorithms ( even for discrete distributions ) have a relatively high execution time [ 15 , 24 , 39 ] . The Lévy-Prokhorov distance have been extensively studied for its theoretical properties [ 11 , 38 ] . For instance , Lévy-Prokhorov distance metrizes weak convergence on any separable metric space [ 19 ] . However , a brute-force algorithm based on the definition of this metric will require a search on exponentially many possible subsets causing it to seldom be used in practice [ 16 ] . However , we use Hall ’ s theorem to show that the computation of the Lévy-Prokhorov metric reduces to the δ-disc graph matching problem and so , it is only as hard as computing the∞-Wasserstein distance , at least for discrete distributions of the type PA and PB described above . In this paper , we provide exact algorithms for computing the∞-Wasserstein and the Lévy-Prokhorov distances for 2-dimensional discrete distributions . Our algorithms can be useful in several scenarios . For instance , one can estimate Lévy-Prokhorov distances between any two fixed-dimensional continuous distributions by simply computing the distances between samples drawn from these distributions . From the fact that the Lévy-Prokhorov distance metrizes weak convergence , for large enough samples we can get accurate distance estimates . Faster high-precision algorithms are critical in obtaining such estimates ; see [ 7 , 6 ] . For high dimensional discrete distributions , Wasserstein distance is sometimes estimated by embedding them into a lower dimensional space and computing high precision solution in this space . For example , see the sliced Wasserstein distance [ 23 ] . In the emerging area of topological data analysis , high dimensional point clouds are characterized by two-dimensional point sets called persistence diagrams where each point represents the so-called birth and death times of a topological feature . Different high-dimensional point clouds can be compared by computing the bottleneck distance between the corresponding diagrams [ 17 , 22 , 1 ] . This has led to development of practical implementations of bottleneck matching algorithms [ 17 , 22 ] . More recently , other Wasserstein distances between persistence diagrams have also been considered . See for instance [ 25 , 40 ] . The special case of computing bottleneck matching for point setsA andB that are drawn uniformly at random from a unit square has also received considerable attention . For instance , it has been used in the context of testing pseudo-random generators , average case analysis of bin packing algorithms [ 29 ] , and also in statistics for analyzing the Glivenko-Cantelli convergence of empirical measures [ 37 ] . δ-disc graphs have other applications as well , including in the modeling of the topology of ad-hoc wireless networks [ 20 ] .

Summary: This work applies a recent approach to maximum cardinality matching due to to Lahn and Raghvendra to a special case relevant to the machine learning community. Namely, they analyze the performance of this approach on delta-disc graphs in the service of computing popular distance metrics. Comparisons are made to the classic Hopcroft-Karp approach with empirical validation.