# 匹配（图论）

在图论中，匹配是选定的一个边集，使得任意两条边不共享端点；匹配问题要求找出这样的边集中最大的一个，或根据变体要求总权重最小或最大的一个。<sup>[1](https://www.geeksforgeeks.org/dsa/hopcroft-karp-algorithm-for-maximum-matching-set-1-introduction/)</sup> 该问题根据图是二分图还是一般图、以及边是否带权重而呈现不同形式，每种形式都有各自的算法解决方案。<sup>[2](https://technav.ieee.org/topic/optimal-matching/)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 匹配是图中一个边集，其中任意两条边不交于同一顶点；即一组顶点不相交的边。<sup>[3](https://nvlpubs.nist.gov/nistpubs/jres/69B/jresv69Bn1-2p125_A1b.pdf)</sup><sup> • </sup><sup>[4](https://link.springer.com/article/10.1365/s13291-022-00247-7)</sup> |
| 最优性判定 | 匹配 M 是最大基数匹配当且仅当不存在关于 M 的增广路径。<sup>[5](https://web.cs.dal.ca/~nzeh/Teaching/4113/book/matching/bipartite_maximum_matching/augmenting_paths.html)</sup> |
| 二分图复杂度 | 二分图中的最大基数匹配由增广路径算法求解，如 Hopcroft-Karp 算法，时间复杂度为 O(√n · m)。<sup>[2](https://technav.ieee.org/topic/optimal-matching/)</sup> |
| 加权二分图情形 | 指派问题——即总权重最小的完美匹配——由匈牙利算法（Kuhn-Munkres 算法）在 O(n³) 时间内求解。<sup>[2](https://technav.ieee.org/topic/optimal-matching/)</sup> |
| 极小极大定理 | 在二分图中，最大匹配的大小等于触及每条边的最小顶点集的大小（König，1931）。<sup>[6](https://api.pageplace.de/preview/DT0400.9780080872322_A25801781/preview-9780080872322_A25801781.pdf)</sup> |
| 一般图 | Edmonds 的花算法（1965）通过将奇环收缩为单个节点来处理奇环，并刻画了匹配多面体。<sup>[7](https://math.mit.edu/~goemans/18433S07/edmonds.pdf)</sup><sup> • </sup><sup>[8](https://doi.org/10.1007/s00373-010-0940-y)</sup> |

## 基本定义

图 G 中的匹配是其边的一个子集，使得任意两条边不交于同一节点。<sup>[3](https://nvlpubs.nist.gov/nistpubs/jres/69B/jresv69Bn1-2p125_A1b.pdf)</sup> 等价地说，它是一组顶点不相交的边：在工人到工作的指派图中，一个有效匹配使每个工人至多得到一份工作，每份工作至多得到一个工人。<sup>[9](https://spacecomplexity.ai/blog/bipartite-matching-algorithm)</sup> 被匹配边触及的顶点称为已匹配的；未被触及的顶点称为暴露的或未匹配的。完美匹配匹配图中每个顶点。

核心量是匹配数，即最大匹配的大小。一个相关的量是触及每条边的最小顶点集的大小，称为最小顶点覆盖（或横截）。当这两个数相等时，称图具有 König–Egerváry 性质；König–Egerváry 图即其最大匹配与最小顶点覆盖等基数的图。<sup>[8](https://doi.org/10.1007/s00373-010-0940-y)</sup><sup> • </sup><sup>[10](https://www.sciencedirect.com/science/article/pii/S0166218X13002072)</sup>

## 增广路径

几乎所有匹配算法的底层工具都是增广路径。给定图 G 中的匹配 M（无论是否为二分图），交替路径是其边在属于 M 和不属于 M 之间交替的路径；增广路径是两个端点均未匹配的交替路径。<sup>[5](https://web.cs.dal.ca/~nzeh/Teaching/4113/book/matching/bipartite_maximum_matching/augmenting_paths.html)</sup> 沿这样的路径交换匹配边和非匹配边的角色（对称差 M ⊕ P）产生一个多一条边的新匹配。

这给出了匹配算法的基础判据：匹配 M 具有最大基数恰好当 G 中不存在关于 M 的增广路径。<sup>[5](https://web.cs.dal.ca/~nzeh/Teaching/4113/book/matching/bipartite_maximum_matching/augmenting_paths.html)</sup> 算法教科书将此定理归功于 Claude Berge。<sup>[11](https://aursbackend.admasuniversity.edu.et/uploads/documents/a995ac49-fe31-40a5-96d6-d5e3a6568b41.pdf)</sup> 贪心算法按遇到分配的顺序锁定分配，可能完全错过最大匹配，这正是二分图匹配算法所要解决的具体问题。<sup>[9](https://spacecomplexity.ai/blog/bipartite-matching-algorithm)</sup> 贪心方法有可证明的局限：Tinhofer 于 1984 年提出的随机 MinGreedy 算法即使对二分图，也以高概率无法超越平凡的 1/2 近似比。<sup>[12](https://arxiv.org/abs/1505.04198)</sup>

## 二分图匹配

在二分图中，顶点集被划分为两类，使得所有边都位于两类之间；任务是找到最大的顶点不相交边集。<sup>[4](https://link.springer.com/article/10.1365/s13291-022-00247-7)</sup> 最大基数版本由增广路径算法求解，其中 Hopcroft-Karp 算法达到 O(√n · m) 时间复杂度，其中 n 为顶点数，m 为边数。<sup>[2](https://technav.ieee.org/topic/optimal-matching/)</sup> 该问题也可转化为流网络并用最大流算法求解。<sup>[1](https://www.geeksforgeeks.org/dsa/hopcroft-karp-algorithm-for-maximum-matching-set-1-introduction/)</sup><sup> • </sup><sup>[13](https://www2.seas.gwu.edu/~hchoi/teaching/cs8211d/GraphTheory.pdf)</sup>

**极小极大结果。** 1931 年 König 证明了在二分图中最大匹配的大小等于共同触及每条边的最小顶点集的大小；同年 Egerváry 将结果推广到每条边带非负权重的图。<sup>[6](https://api.pageplace.de/preview/DT0400.9780080872322_A25801781/preview-9780080872322_A25801781.pdf)</sup> 1935 年 Hall 独立证明了一个等价结果，后被广泛称为婚姻定理。<sup>[4](https://link.springer.com/article/10.1365/s13291-022-00247-7)</sup> 在有史以来第一本图论教科书中，König（1936）表明关于连通性的 Menger 定理、Frobenius 的婚姻定理和 P. Hall 的相异代表定理都可由他的极小极大定理推出，而这些结果连同最大流最小割定理和关于偏序集的 Dilworth 定理都是等价的。<sup>[6](https://api.pageplace.de/preview/DT0400.9780080872322_A25801781/preview-9780080872322_A25801781.pdf)</sup>

**指派问题。** 在称为指派问题的加权二分图形式中，目标是找到总权重尽可能小的完美匹配；匈牙利算法（也称 Kuhn-Munkres 算法）在 O(n³) 时间内求解。<sup>[2](https://technav.ieee.org/topic/optimal-matching/)</sup><sup> • </sup><sup>[14](https://epubs.siam.org/doi/abs/10.1137/S0097539794267243)</sup> 它是最小费用流和运输问题的重要特例，可行匹配是一个子图，其中源集中的每个节点恰好与目标集中的一个节点相邻。<sup>[15](https://fabioschoen.github.io/OptimizationModels/html/Assignment.html)</sup> 受大学课程中将学生分配到项目的启发，带顶点上下配额的变体具有性能保证为 u_max + 1 的近似算法，除非 P = NP，否则渐近最优。<sup>[16](https://arxiv.org/abs/1412.0325)</sup>

## 一般（非二分图）匹配

对于非二分图，结构更为复杂，因为必须显式处理奇环。<sup>[2](https://technav.ieee.org/topic/optimal-matching/)</sup> 从暴露顶点出发的朴素搜索可能找到 Edmonds 分析所称的花：一条偶交替路径（茎）终止于一个奇环，环的边在匹配内外交替（花苞），该结构不一定包含增广路径。<sup>[7](https://math.mit.edu/~goemans/18433S07/edmonds.pdf)</sup>

**Edmonds 的花算法。** Jack Edmonds 1965 年的算法要么找到增广路径或花，要么证明两者均不存在——此时匹配为最大。当找到花苞 B 时，算法将其收缩为一个顶点，得到图 G/B 和匹配 M/B；一个关键定理保证 M 在 G 中最大恰好当 M/B 在 G/B 中最大，从而使算法可递归进行并撤销收缩以恢复最终解。<sup>[7](https://math.mit.edu/~goemans/18433S07/edmonds.pdf)</sup> 在同一篇 1965 年论文中，Edmonds 刻画了其极点对应于图的匹配的凸多面体，并描述了当每条边带实数权重时寻找最大权重和匹配的高效算法；难度随图规模的增长不是指数的。<sup>[3](https://nvlpubs.nist.gov/nistpubs/jres/69B/jresv69Bn1-2p125_A1b.pdf)</sup> 完美匹配多面体由两族约束描述：顶点饱和约束和花苞约束；花苞约束可由顶点饱和约束蕴含的图称为非 Edmonds 图，König–Egerváry 图即属此类。<sup>[8](https://doi.org/10.1007/s00373-010-0940-y)</sup>

**Tutte-Berge 公式。** 对任意图 G = (V, E)，最大匹配的大小由极小极大关系给出：max |M| = min_{U ⊆ V} ½(|V| + |U| − o(G \ U))，其中 o(G \ U) 是 G \ U 的奇数大小连通分支数。<sup>[7](https://math.mit.edu/~goemans/18433S07/edmonds.pdf)</sup>

非二分图匹配在实践中计算上更难：不能使用简单的二分图最优匹配算法，非二分图匹配只能归约为带双向图的最大流问题的扩展，而后者没有简单解法；广泛接受的算法搜索增广路径。<sup>[17](https://pmc.ncbi.nlm.nih.gov/articles/PMC3501247/)</sup>

## 应用

**指派与调度。** 二分图匹配是调度和指派任务的基础，如将工人分配到工作、在全国住院医师匹配计划下将医学住院医师匹配到医院。<sup>[2](https://technav.ieee.org/topic/optimal-matching/)</sup> NRMP 的匹配算法是申请人提议的：它试图将每位申请人安排到申请人排序列表上最偏好的项目，沿列表下移直到获得暂定匹配或选择耗尽；当所有排序列表都被考虑后，暂定匹配成为最终结果。<sup>[18](https://www.nrmp.org/intro-to-the-match/how-matching-algorithm-works/)</sup> Roth-Peranson 匹配算法是 APPIC 匹配的核心，是 Alvin Roth 获得 2012 年诺贝尔经济学奖的关键，并被用于世界各地的市场设计应用。<sup>[19](https://www.appic.org/Match/FAQs/Intro-to-the-Match)</sup>

**肾脏交换。** 在肾脏配对捐赠中，患者-捐赠者对是无向图的顶点，边连接相互兼容的对；由于某些匹配在地理上不理想且移植结果取决于免疫学一致性，边被赋予权重，寻求最大边权匹配。<sup>[20](https://arxiv.org/abs/1710.00953)</sup> 视为清算问题，肾脏交换可建模为有向图中的环包装，环长度为 2、3 或更长；一个精确算法已为 NHS 血液与移植部门运行的全国配对捐赠匹配计划的真实问题提供了最优解。<sup>[21](https://eprints.gla.ac.uk/25732/)</sup> 最先进的匹配引擎依赖整数规划，当兼容图允许使用固定数量的患者和捐赠者属性进行编码时，清算可在多项式时间内完成；对美国 UNOS 全国兼容图的测试表明少量属性就足够了。<sup>[22](https://ojs.aaai.org/index.php/AAAI/article/view/10593)</sup>

**统计学。** 最优非二分图匹配用于超越两组情形的观察性研究设计，寻找在给定距离矩阵下使距离之和最小的匹配集；当最优匹配唯一时，它将最优二分图匹配作为特例包含在内，并支持多组比较和比较多元分布的无分布检验。<sup>[17](https://pmc.ncbi.nlm.nih.gov/articles/PMC3501247/)</sup>

## References

1. [Maximum Bipartite Matching / Hopcroft-Karp introduction, GeeksforGeeks](https://www.geeksforgeeks.org/dsa/hopcroft-karp-algorithm-for-maximum-matching-set-1-introduction/)
2. [Optimal Matching, IEEE Technology Navigator](https://technav.ieee.org/topic/optimal-matching/)
3. [Jack Edmonds (1965). Maximum Matching and a Polyhedron With 0,1-Vertices. J. Res. Nat. Bur. Standards 69B.](https://nvlpubs.nist.gov/nistpubs/jres/69B/jresv69Bn1-2p125_A1b.pdf)
4. [Graph Theory – A Survey on the Occasion of the Abel Prize for László Lovász, Jahresbericht der DMV](https://link.springer.com/article/10.1365/s13291-022-00247-7)
5. [Augmenting Paths, Algorithms II (Dalhousie University)](https://web.cs.dal.ca/~nzeh/Teaching/4113/book/matching/bipartite_maximum_matching/augmenting_paths.html)
6. [Matching Theory (Lovász & Plummer), book preview](https://api.pageplace.de/preview/DT0400.9780080872322_A25801781/preview-9780080872322_A25801781.pdf)
7. [Lecture notes on non-bipartite matching, MIT (Michel X. Goemans)](https://math.mit.edu/~goemans/18433S07/edmonds.pdf)
8. [P. Mark Kayll (2010). König–Egerváry Graphs are Non-Edmonds. Graphs and Combinatorics 26, 721–726.](https://doi.org/10.1007/s00373-010-0940-y)
9. [What Is Bipartite Matching? The Assignment Problem, Explained, SpaceComplexity](https://spacecomplexity.ai/blog/bipartite-matching-algorithm)
10. [Forbidden subgraphs and the König–Egerváry property, Discrete Applied Mathematics](https://www.sciencedirect.com/science/article/pii/S0166218X13002072)
11. [Algorithms textbook excerpt (Levitin), Admas University repository](https://aursbackend.admasuniversity.edu.et/uploads/documents/a995ac49-fe31-40a5-96d6-d5e3a6568b41.pdf)
12. [Greedy Matching: Guarantees and Limitations, arXiv:1505.04198](https://arxiv.org/abs/1505.04198)
13. [Graph Theory: Introduction, GWU lecture notes](https://www2.seas.gwu.edu/~hchoi/teaching/cs8211d/GraphTheory.pdf)
14. [Linear and Time Minimum-Cost Matching Algorithms for Quasi-Convex Tours, SIAM Journal on Computing](https://epubs.siam.org/doi/abs/10.1137/S0097539794267243)
15. [Assignment or bi-partite matching, OptimizationModels documentation](https://fabioschoen.github.io/OptimizationModels/html/Assignment.html)
16. [Matchings with lower quotas: Algorithms and complexity, arXiv:1412.0325](https://arxiv.org/abs/1412.0325)
17. [Bo Lu et al. (2011). Optimal Nonbipartite Matching and Its Statistical Applications. PMC3501247.](https://pmc.ncbi.nlm.nih.gov/articles/PMC3501247/)
18. [How the Matching Algorithm Works, National Resident Matching Program](https://www.nrmp.org/intro-to-the-match/how-matching-algorithm-works/)
19. [APPIC Match FAQs: Intro to the Match](https://www.appic.org/Match/FAQs/Intro-to-the-Match)
20. [Maximum Matchings in Graphs for Allocating Kidney Paired Donation, arXiv:1710.00953](https://arxiv.org/abs/1710.00953)
21. [Maximum weight cycle packing in directed graphs, with application to kidney exchange programs, University of Glasgow](https://eprints.gla.ac.uk/25732/)
22. [Small Representations of Big Kidney Exchange Graphs, AAAI](https://ojs.aaai.org/index.php/AAAI/article/view/10593)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Graph theory › Graph theory overview and basic objects

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/matching-graph-theory

English original: https://www.edgepedia.org/matching-graph-theory
