Optimal Matching between Point Clouds
This opening chapter isolates the simplest form of optimal transport: pairing two finite, equally weighted point clouds of the same cardinality. The stakes are algorithmic and geometric at once: one sees the combinatorial nature of transport, the special simplicity of the line, and the limitations of permutations once cardinalities or weights differ. Classical assignment algorithms such as the Hungarian and auction methods Kuhn, 1955Bertsekas, 1992 provide the computational backdrop, while the restriction to equal cardinalities and weights motivates the Kantorovich relaxation.
Monge Problem for Discrete Points¶
This section formulates matching as Monge’s deterministic transport problem on two equally weighted clouds. The one-dimensional case is a transparent reference case where the optimal map can be read off by sorting.
Assignment Problem¶
Let be a cost matrix, where is the cost of pairing source with target , and let denote the bijections of . The optimal assignment problem is
When , this is the Monge problem between the two uniform empirical measures. The factor records the mass of each atom but does not change the optimizer. Exhaustive search evaluates all permutations and is therefore impractical. Without additional assumptions on , the optimizer need not be unique.
Convex Costs on the Line¶
In one dimension, convex costs select monotone matchings.
Proof
An assignment that does not preserve order contains an inversion: after relabeling, are matched to . Set and
Strict convexity makes strictly increasing. Therefore
This quantity is positive because . Swapping the inverted targets strictly lowers the cost. Repeating the exchange eliminates every inversion; the only order-preserving bijection between the sorted clouds pairs equal ranks.
For convex but not strictly convex , the same exchange inequality is non-strict. Equal-rank matching remains optimal, but other optimizers may coexist. Choose sorting permutations such that
and then map to . Equivalently, an optimal transport is . Comparison sorting costs in the worst case with mergesort or heapsort; quicksort has this complexity only in expectation.
Concave Costs on the Line¶
Concavity reverses the exchange preference: one long and one short displacement can cost less than two displacements of intermediate length. Thus costs with strictly concave and nondecreasing, such as for , favor nested or crossing assignments rather than equal ranks. This is the regime studied by Gangbo and McCann Gangbo & McCann, 1996.
For a source point, its right neighbor is the nearest target to its right such that the intervening open interval contains equally many sources and targets; left neighbors and target-to-source neighbors are defined symmetrically. Iterating this balanced-neighbor relation partitions a unit-mass problem into independent alternating chains. On a chain
with the opposite orientation handled by exchanging and , the local indicators are
and
After the relevant lower-order indicators have been found nonnegative, a negative certifies , while a negative certifies , for . Recursively removing certified blocks gives an exact algorithm for equal unit masses; the extension to arbitrary real masses has a larger worst-case bound Delon et al., 2012. Repeatedly matching the closest red-blue pair is a simpler heuristic, with quantitative guarantees for when Ottolini & Steinerberger, 2025.
Figure Div contrasts this alternating-chain behavior with monotone rank matching for a convex cost, first on unimodal clouds and then on multimodal clouds.

One-dimensional assignments for ordered source and target clouds with costs . The top row uses single-Gaussian source and target clouds; the bottom row uses a denser two-component source and three-component target. For the convex quadratic cost, equal ranks are matched and the segments do not cross. For the concave cost, the optimum creates long crossing exchanges; the ordered line remains useful, but through the alternating-chain structure of concave transport rather than through monotone rearrangement.
Interactive panel. Use the sliders to change the two cost exponents and see how convex costs preserve sorted, non-crossing matches while concave costs favor longer crossing exchanges.
The next figure shows the monotone case more explicitly. The red and blue curves are smooth laws used to generate equal-weight empirical measures; the dots are inverse-CDF samples at common quantile levels. The monotone assignment connects equal ranks.
Figure Div isolates the rank-matching mechanism for both unimodal and multimodal laws: sampling the two quantile functions at the same levels produces the non-crossing optimal assignment.

One-dimensional optimal matching by quantile sorting. The red and blue curves are smooth laws used to generate equal-weight empirical measures; the dots are inverse-CDF samples at common quantile levels. The monotone assignment connects equal ranks, both for two Gaussian mixtures and for the transport from one central Gaussian toward a three-mode target law.
The interactive panel exposes the point count and the two laws while keeping the monotone equal-rank construction in the background.

Interactive panel. Use the point-count slider and the source/target menus to redraw the one-dimensional monotone assignment. The dots move, but the rule remains equal-rank matching after sorting.
Histogram Equalization¶
If is strictly increasing and is convex and nondecreasing, sorting also solves the problem with cost . A typical application is grayscale histogram equalization. For equal-size samples with distinct ranks, monotone rearrangement gives the exact assignment to a prescribed target histogram. Repeated intensities require consistent tie-breaking or mass splitting, but the quantile construction remains canonical. It matches intensity distributions rather than spatial pixel locations.
Figure Div applies this construction to image intensities and shows simultaneously the interpolated images and the monotone evolution of their histograms.

Histogram equalization as one-dimensional Monge transport on pixel intensities. The map is the monotone rearrangement ; here is a truncated Gaussian concentrated near dark intensities. The images are interpolated pointwise by , and all histograms share the same vertical scale.
The interactive view below exposes the target mean, target standard deviation, and interpolation time.

Interactive panel. Use the mean, standard-deviation, and time sliders to move the target intensity law and follow the resulting image equalization and histogram deformation.
Flat Directions for the Linear Cost¶
Strict convexity makes every optimizer increasing and, for distinct points, unique. For a merely convex cost such as , non-increasing optimal assignments can coexist. The next example exhibits a genuine flat direction of the linear cost.
Optimal Transport on the Circle¶
The sorting rule on the line has a periodic analogue. Identify the circle with , let
The only extra datum, compared with the line, is where one opens the circle. Once a cut has been chosen, the circle is unfolded into an interval and the one-dimensional monotone assignment can be used. In the discrete case, changing the cut is the same as applying a cyclic shift to one of the two circular orderings.
Proof
Fix an optimal assignment and let be an open shortest arc from to its matched target, choosing either orientation for an antipodal pair. The path-uncrossing lemma of Delon, Rabin, and Gousseau says that if two arcs of an optimal assignment intersect, then they have the same orientation and neither is strictly contained in the other Rabin et al., 2011. Indeed, opposite orientations or strict containment would allow a two-edge exchange that is strictly cheaper by monotonicity and strict convexity of .
Suppose that the arcs cover the circle. Because they are open, every source lies in another transport arc. Ordering the sources cyclically and applying the path-uncrossing lemma propagates a common orientation: either each forward neighbor lies in the preceding arc, or the analogous statement holds backward. Cyclically reassigning the targets in that orientation then shortens every arc, contradicting optimality. Hence a point lies outside their union.
Cut at and lift the circle to . Each matched geodesic avoids the cut, so its circular length is the ordinary distance between its lifted endpoints. The monotone matching proposition on the line implies that the lifted assignment preserves order. An order-preserving bijection between two cyclically ordered finite sets is a cyclic shift. Minimizing over the shifts therefore recovers the optimum. The argument and its extensions to convex costs and nonuniform masses are developed in Rabin et al., 2011Delon et al., 2010.
Figure Div shows how the selected cut turns the circular assignment into an ordinary ordered matching on an interval.

Optimal transport on the circle by cutting and unfolding. Purple segments show the optimal matching and the green radius marks the chosen cut. The red and blue atoms live on two copies of the circle; the denser point clouds make the cyclic ordering visible. Once the circle is opened at this angle, the same matching appears as a monotone one-dimensional assignment on the interval, with the two green endpoints identified.
Interactive panel. Use the number of points, exponent, and shift controls to open the circle at different cuts and compare the induced cyclic assignments.
Figure Div returns to planar assignments and shows that, even for fixed point clouds, changing the exponent of the Euclidean cost can reorganize the optimal permutation globally.

Optimal assignments between the same two point clouds for four powers of the Euclidean distance. The source atoms are semi-regular samples in a central disk, while the target atoms are semi-regular samples on a thin annulus; this canonical geometry is reused in later coupling and regularization figures. The feasible set is unchanged, but changing changes the global organization of the permutation: the concave case penalizes long edges only sublinearly and therefore permits longer exchanges, whereas larger powers increasingly suppress the longest edges.
The interactive panel reuses the same disk-to-annulus geometry and exposes the number of points, the data geometry, and the cost exponents in .

Interactive panel. Use the exponent sliders to compare how different powers of the distance reshape the same two-dimensional assignment problem.
Two-Dimensional Assignments¶
Sorting no longer orders a planar cloud, but a simple local exchange still rules out proper crossings for the Euclidean-distance cost. This observation, already present in Monge’s geometric reasoning, is necessary but far from sufficient for computing an optimum.
Proof
Suppose that and cross properly at . The triangle inequality along the two reconnected paths gives
and the analogous inequality after exchanging and . The sum of the right-hand sides is the cost of the two original segments. At least one inequality is strict because the crossing is non-collinear. Swapping the two targets therefore strictly decreases the cost, a contradiction. Collinear overlaps are excluded because the exchange can then have equal cost.
This property alone is not enough to lead to an efficient algorithm. Non-crossing is only a necessary local test, not a compact certificate of optimality. For instance, if sources and targets are placed alternately on the boundary of a convex polygon, the number of non-crossing perfect matchings is the Catalan number
Thus even after forbidding proper crossings, exhaustive search remains exponential. The two-segment swap explains why a transverse crossing cannot be optimal, but it does not select among the exponentially many planar matchings that survive this local test.
After sorting, direct enumeration costs . Faster methods exploit the convex dependence of the circular transport cost on a continuous shift parameter for weighted histograms Delon et al., 2010.
Hungarian Algorithm¶
We now present a first algorithm for solving the optimal matching problem. The Hungarian method Kuhn, 1955Burkard et al., 2009 provides a gentle, self-contained preview of duality: it computes a permutation together with a certificate of its optimality. The auction algorithm Bertsekas, 1981Bertsekas, 1992 is postponed to Section Auction Algorithm, after discrete duality and the semi-dual formulation have been fully developed.
Hungarian Primal-Dual Method¶
The method constructs an assignment and its optimality certificate simultaneously. Its derivation below uses only the elementary lower bound derived next; Section Discrete Dual later embeds this certificate in general discrete Kantorovich duality.
The factor in the assignment objective does not affect its optimizer, so consider the unnormalized dual problem
The certificate used by both Hungarian and auction methods is worth isolating.
Proof
Dual feasibility gives for every . Summing and using that permutes the target indices yields
If all edges selected by are tight, its assignment cost equals the dual value of . The lower bound shows that no permutation has smaller cost. Applied to and any other feasible dual pair, it also shows that no feasible dual value can exceed this cost. Conversely, the difference is the sum of the nonnegative slacks , and it vanishes exactly when every one of these slacks vanishes.
This is exactly the uniform-mass specialization of the discrete Kantorovich dual (2), multiplied by .
The method maintains feasible potentials and a partial matching , meaning a set of source--target pairs in which no vertex occurs twice. Its slack, or reduced cost, is
The equality graph consists precisely of the zero-slack edges,
The invariant means that every matched pair already saturates its dual constraint. If is perfect, Proposition Proposition: Dual Certificate for an Assignment certifies that its associated permutation is optimal. It remains to enlarge while preserving dual feasibility and .
To increase the matching, choose an unmatched source . Starting from that root, grow a tree in the bipartite equality graph. From a reached source, follow a zero-slack edge to a new target; from a reached target that is already matched, follow its unique matched edge back to a source. The tree edges therefore alternate between unmatched and matched edges, which explains the term alternating tree. Write for the source preceding a reached target , and for the matched target preceding a reached non-root source . If the tree reaches an unmatched target, these pointers form an augmenting path. Exchanging matched and unmatched edges along this path increases by one.
Let and denote the reached source and target sets, and let . If no equality edge leaves toward an unreached target, shift the potentials by the smallest such slack:
Here because no edge from to is currently tight. The update leaves slacks unchanged on , decreases them by on , and increases them on . Feasibility and existing tree edges are preserved, while at least one new equality edge appears from to . Since before a free target is reached, the dual objective increases by .
A cubic implementation stores, for every unreached target,
and a parent source attaining the minimum. When a source enters , each unreached target is updated by comparing with the single new slack . A dual shift uses and replaces by for . A tree expansion therefore costs rather than requiring a rescan of .
Hungarian and auction methods use the same dual potentials and reduced costs in different ways. Hungarian grows an exact zero-slack augmenting tree, whereas the auction method in Section Auction Algorithm uses -relaxed contacts, price bids, and ownership changes. Figure Div shows the Hungarian mechanism on the same planar clouds as Figure Div: thick violet edges form the current matching, while faint edges indicate unmatched pairs whose reduced costs are closest to zero.

Growth of the Hungarian matching on the planar point clouds of Figure Div. Thick violet segments show the partial matching, whose cardinality is reported in each panel. Thin translucent segments show the lowest-slack unmatched edges, ranked by ; exact zero-slack candidates are slightly stronger. This overlay summarizes the near-tight dual constraints, while the algorithm selects its next edge only across the current alternating-tree cut. The final thick matching is optimal and all its edges are dual-tight.
Interactive panel. Use the size, jitter, and seed controls to regenerate an assignment instance and inspect the augmentation process. The static book figure above fixes the canonical point clouds and additionally overlays low-slack edges.
Proof
Initialization is dual feasible and the empty matching lies in the equality graph. At the beginning of a phase, the slack initialization gives
This identity is preserved when a matched source enters , because the algorithm compares every with the single new candidate .
Before a free target is reached, every target in is matched to a source in , while every source in except the unmatched root was reached through its matched target. Thus , so cannot contain every target. Dual feasibility gives
After the potential update,
All slacks remain nonnegative. For , both the slacks from and decrease by , so the maintained-minimum identity remains valid. At least one becomes zero, and supplies the corresponding equality edge. Every matched edge remains tight.
Each inner iteration adds a new target to . It either reaches a free target or adds that target’s matched source to and updates the slack array. Hence a phase reaches a free target after at most iterations. The pointers and trace an alternating path; flipping it preserves the matching property, increases by one, and uses only equality edges. Starting from the empty matching, exactly phases produce a perfect matching.
At termination every matched edge is tight, so Proposition Proposition: Dual Certificate for an Assignment directly proves that is optimal and the returned potentials are dual optimal. This is the finite assignment instance of the complementary-slackness mechanism proved in general in Proposition Proposition: Discrete Complementary Slackness. Initializing the slack array costs . Each inner iteration scans at most targets to find , update the slacks, and compare them with one newly reached source row. It therefore costs , giving per phase and overall. The cost matrix requires storage, while the matching, reached sets, parent arrays, and slacks require only additional storage.
The chapter has exposed two complementary routes to finite matching: geometry can reduce the problem to sorting, while primal-dual potentials give a global certificate for an arbitrary cost matrix. The next chapter passes from finite permutations to transport maps between general measures.
- Kuhn, H. W. (1955). The Hungarian Method for the Assignment Problem. Naval Research Logistics Quarterly, 2(1–2), 83–97. 10.1002/nav.3800020109
- Bertsekas, D. P. (1992). Auction algorithms for network flow problems: a tutorial introduction. Computational Optimization and Applications, 1(1), 7–66.
- Gangbo, W., & McCann, R. J. (1996). The geometry of optimal transportation. Acta Mathematica, 177(2), 113–161.
- Delon, J., Salomon, J., & Sobolevski, A. (2012). Local matching indicators for transport problems with concave costs. SIAM Journal on Discrete Mathematics, 26(2), 801–827. 10.1137/110823304
- Ottolini, A., & Steinerberger, S. (2025). Greedy Matching in Optimal Transport with Concave Cost. Annales Fennici Mathematici, 50(2), 549–562. 10.54330/afm.173113
- Rabin, J., Delon, J., & Gousseau, Y. (2011). Transportation Distances on the Circle. Journal of Mathematical Imaging and Vision, 41(1–2), 147–167. 10.1007/s10851-011-0284-0
- Delon, J., Salomon, J., & Sobolevski, A. (2010). Fast transport optimization for Monge costs on the circle. SIAM Journal on Applied Mathematics, 70(7), 2239–2258. 10.1137/090772708
- Burkard, R., Dell’Amico, M., & Martello, S. (2009). Assignment problems. Society for Industrial.
- Bertsekas, D. P. (1981). A new algorithm for the assignment problem. Mathematical Programming, 21(1), 152–171.