Papers
Topics
Authors
Recent
Search
2000 character limit reached

Hungarian-Matching Algorithm

Updated 23 June 2026
  • Hungarian-Matching Algorithm is a polynomial-time combinatorial method that determines maximum-weight perfect matchings in bipartite graphs.
  • It employs feasible labeling, slack management, and alternating tree searches to iteratively adjust dual variables and converge to optimal solutions.
  • The algorithm underpins many applications in resource allocation, market design, and network scheduling, demonstrating both theoretical rigor and practical utility.

The Hungarian-Matching Algorithm, often referred to as the Kuhn–Munkres algorithm, is a polynomial-time combinatorial optimization method for solving the assignment problem—namely, determining a maximum-weight perfect matching in a weighted bipartite graph. Since its introduction, the algorithm has been recognized as a cornerstone in operational research, mathematical optimization, and computer science for its use in assignment and resource allocation problems, and has evolved into numerous generalizations and domain-specific adaptations.

1. Mathematical Formulation and Duality

Given a bipartite graph G=(U,V,E)G = (U, V, E) with ∣U∣=∣V∣=n|U| = |V| = n and real edge weights wijw_{ij} for (i,j)∈E(i, j) \in E, the assignment problem seeks a perfect matching M⊆EM \subseteq E maximizing the total weight ∑(i,j)∈Mwij\sum_{(i, j) \in M} w_{ij}. The integer linear programming formulation is:

  • Primal (P):

maximize      ∑i∈U∑j∈Vwijxij\text{maximize} \;\;\; \sum_{i \in U}\sum_{j \in V} w_{ij} x_{ij}

subject to      ∑j∈Vxij=1  ∀i∈U;∑i∈Uxij=1  ∀j∈V;xij∈{0,1}\text{subject to} \;\;\; \sum_{j \in V} x_{ij} = 1 \;\forall i \in U;\quad \sum_{i \in U} x_{ij} = 1\; \forall j \in V;\quad x_{ij} \in \{0,1\}

  • Dual (D):

minimize    ∑i∈Uui+∑j∈Vvj\text{minimize} \;\; \sum_{i \in U} u_i + \sum_{j \in V} v_j

subject to    ui+vj≥wij    ∀(i,j)∈E\text{subject to} \;\; u_i + v_j \geq w_{ij} \;\; \forall (i,j) \in E

Strong duality and integrality ensure optimal matchings correspond to feasible dual solutions satisfying complementary slackness (Chen et al., 2019).

2. Algorithmic Structure: Feasible Labelings, Slack, and the Equality Graph

A feasible labeling ∣U∣=∣V∣=n|U| = |V| = n0 satisfies ∣U∣=∣V∣=n|U| = |V| = n1 for all ∣U∣=∣V∣=n|U| = |V| = n2. The slack of an edge is ∣U∣=∣V∣=n|U| = |V| = n3. Central to the Hungarian method is the equality subgraph ∣U∣=∣V∣=n|U| = |V| = n4, which encodes all tight edges at each iteration.

The iterative process maintains a feasible labeling, performing alternating-tree search in the current equality subgraph to identify augmenting paths. If no such path can be found for a free row, the dual variables are updated via label adjustment by the minimum slack in the current tree, thus ensuring progress and eventual convergence to optimality (Chen et al., 2019).

Pseudocode for the canonical algorithm reflects this structure, with initialization, alternating-tree growth, slack management, label updating, and augmentation encapsulated in ∣U∣=∣V∣=n|U| = |V| = n5 time (see detailed pseudocode in (Chen et al., 2019)).

3. Generalizations and Extensibility

3.1 Non-square and Rectangular Assignment

The algorithm extends to rectangular cost matrices (∣U∣=∣V∣=n|U| = |V| = n6) by padding with additional dummy rows or columns, enabling the solution of generalized assignment problems such as those in school choice (Aksoy et al., 2010) or pilot assignment in wireless networks (Buzzi et al., 2020), where capacity constraints, non-square matchings, or auxiliary constraints apply.

3.2 Many-to-Many and Capacity-Constrained Matching

The Hungarian framework can be extended to many-to-many matchings with demands and capacities (MMDC), as in the setting of Rajabi-Alni & Bagheri (Rajabi-Alni et al., 2022). This is achieved by "cloning" each vertex (expanding node multiplicity according to demand/capacity parameters) and constructing an augmented bipartite graph amenable to the classical algorithm. The optimality and correctness of the reduction are established via structured edge weights and auxiliary vertices, at the expense of increased instance size and time complexity up to ∣U∣=∣V∣=n|U| = |V| = n7 in general.

3.3 Assignment Problems with Structured Constraints

The Hungarian algorithm has been generalized to settings such as:

Further, modifications of the Hungarian approach have been proposed to address non-standard optimal transport (OT) problems with one-to-many assignments and structured marginals, reducing computational complexity compared to direct reductions to square assignment instances (Xie et al., 2022).

4. Complexity Analysis and Algorithmic Optimizations

  • Standard Hungarian: ∣U∣=∣V∣=n|U| = |V| = n8 for a bipartite graph with ∣U∣=∣V∣=n|U| = |V| = n9 vertices on each side and wijw_{ij}0 edges. Each outer iteration grows the matching by one, each alternating-tree expansion and label update costing wijw_{ij}1 (Chen et al., 2019).
  • Rectangular/Unbalanced Instances: Time remains wijw_{ij}2 after padding.
  • Capacity-Constrained Extensions: For MMDC, complexity may increase to wijw_{ij}3, but practical reductions in graph size or sparse/demand-limited scenarios enable faster runs (Rajabi-Alni et al., 2022).
  • Sparse Graphs and Fast Variants: On sparse graphs, Hungarian-style modifications leveraging efficient slack arrays and containerized sets can reduce empirical complexity below wijw_{ij}4, with wijw_{ij}5 observed on random graphs (Kwok, 28 Feb 2025).
  • Approximate Matching: For quadratic ground cost (plane-RMS matching), adaptation to specialized data structures (e.g., quadtree and compressed graphs) yields wijw_{ij}6 approximate solvers (Lahn et al., 2020).
  • Randomized Sparsification: For specific statistical estimation settings, sparsification reduces the matching graph to wijw_{ij}7 edges, achieving high-probability optimality with provable excess-risk bounds (Chewi et al., 2018).

5. Applications Across Domains

5.1 Classical Assignment and Resource Scheduling

The original context, as in the assignment of staff to tasks, is mathematically abstracted as an assignment problem in a bipartite graph. The Hungarian algorithm optimally solves such problems efficiently, outperforming brute-force enumeration (Chen et al., 2019).

5.2 Market Design and School Choice

Adaptation to educational assignment leverages the algorithm for student-optimal, Pareto-efficient allocation under ordinal preferences, possible capacity constraints, and strategic behavior (Aksoy et al., 2010).

5.3 Wireless Communications and MIMO Scheduling

In multiuser MIMO, the Hungarian algorithm is deployed for user–beam assignment, maximizing network utility within each scheduling iteration (Khan et al., 2020). Similarly, pilot sequence allocation in massive MIMO exploits iterative Hungarian matching for throughput or fairness objectives (Buzzi et al., 2020).

5.4 Physics: Atomic Array Assembly

Optimal atom–site assignments with minimal collision probability are efficiently solved using a convex power-law cost metric in conjunction with the Hungarian algorithm, outperforming heuristic and brute-force baseline methods in constructing defect-free atomic arrays (Lee et al., 2017).

5.5 Optimal Transport and Statistical Estimation

Optimal transport instances with specific structural constraints are addressed with modified Hungarian algorithms, yielding substantial runtime improvements and maintaining exactness (Xie et al., 2022). In high-dimensional statistical estimation problems, the matching-based MLE can be computed via Hungarian matching or sparsified variants (Chewi et al., 2018).

5.6 Generalized Graph Theoretic Contexts

The augmenting-path and dual adjustment paradigm extends to hypergraph matching under strengthened Haxell-type conditions, with the core Hungarian logic preserved and generalizations addressing wider combinatorial structures (Annamalai, 2015).

6. Theoretical Guarantees, Proofs of Optimality, and Empirical Performance

Correctness is certified by dual feasibility and complementary slackness; once a perfect matching in the equality subgraph is reached, primal and dual solutions are optimal and matching costs coincide (Chen et al., 2019). Empirical comparisons repeatedly demonstrate that the Hungarian algorithm dominates brute-force and heuristic greedy assignment methods both in solution quality and computational efficiency (Lee et al., 2017). In specialized OT contexts, direct Hungarian-style solvers yield lower runtime and greater accuracy versus Sinkhorn and network simplex methods, particularly in high-dimensional or structured-marginal settings (Xie et al., 2022).

7. Summary Table: Algorithmic Scope and Complexity

Variant / Domain Time Complexity Citation
Classical (square) assignment wijw_{ij}8 (Chen et al., 2019)
Rectangular assignment (with padding) wijw_{ij}9 (Aksoy et al., 2010)
Many-to-many with capacity/demand (vertex cloning) (i,j)∈E(i, j) \in E0 worst case (Rajabi-Alni et al., 2022)
Modified OT for product marginals (i,j)∈E(i, j) \in E1 (Xie et al., 2022)
Sparse bipartite, fast variant (i,j)∈E(i, j) \in E2 (avg.) (Kwok, 28 Feb 2025)
RMS distance (approximate) (i,j)∈E(i, j) \in E3 (Lahn et al., 2020)

The Hungarian-matching algorithm and its descendant methodologies continue to underpin advances in combinatorial optimization, operational research, and domain-specific large-scale assignment problems, offering robust theoretical guarantees and practical performance across an expanding range of applications.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Hungarian-Matching Algorithm.