Matching (graph theory)

In the mathematical discipline of graph theory, a matching or independent edge set in an undirected graph is a set of edges without common vertices.[1] Finding a matching in a bipartite graph can be treated as a network flow problem.

1 Definitions

Given a graph G = (V, E), a matching M in G is a set of pairwise non-adjacent edges, none of which are loops; that is, no two edges share common vertices.

A vertex is matched (or saturated) if it is an endpoint of one of the edges in the matching. Otherwise the vertex is unmatched (or unsaturated).

A maximal matching is a matching M of a graph G that is not a subset of any other matching. A matching M of a graph G is maximal if every edge in G has a non-empty intersection with at least one edge in M. The following figure shows examples of maximal matchings (red) in three graphs.

Maximal-matching.svg
A maximum matching (also known as maximum-cardinality matching[2]) is a matching that contains the largest possible number of edges. There may be many maximum matchings. The matching number {\displaystyle \nu (G)}\nu (G) of a graph G is the size of a maximum matching. Every maximum matching is maximal, but not every maximal matching is a maximum matching. The following figure shows examples of maximum matchings in the same three graphs.

Maximum-matching-labels.svg
A perfect matching is a matching that matches all vertices of the graph. That is, a matching is perfect if every vertex of the graph is incident to an edge of the matching. Every perfect matching is maximum and hence maximal. In some literature, the term complete matching is used. In the above figure, only part (b) shows a perfect matching. A perfect matching is also a minimum-size edge cover. Thus, the size of a maximum matching is no larger than the size of a minimum edge cover: {\displaystyle \nu (G)\leq \rho (G)}{\displaystyle \nu (G)\leq \rho (G)}. A graph can only contain a perfect matching when the graph has an even number of vertices.

A near-perfect matching is one in which exactly one vertex is unmatched. Clearly, a graph can only contain a near-perfect matching when the graph has an odd number of vertices, and near-perfect matchings are maximum matchings. In the above figure, part © shows a near-perfect matching. If every vertex is unmatched by some near-perfect matching, then the graph is called factor-critical.

Given a matching M, an alternating path is a path that begins with an unmatched vertex[3] and whose edges belong alternately to the matching and not to the matching. An augmenting path is an alternating path that starts from and ends on free (unmatched) vertices. Berge’s lemma states that a matching M is maximum if and only if there is no augmenting path with respect to M.

An induced matching is a matching that is the edge set of an induced subgraph.[4]

2 Properties

In any graph without isolated vertices, the sum of the matching number and the edge covering number equals the number of vertices.[5] If there is a perfect matching, then both the matching number and the edge cover number are |V | / 2.

If A and B are two maximal matchings, then |A| ≤ 2|B| and |B| ≤ 2|A|. To see this, observe that each edge in B \ A can be adjacent to at most two edges in A \ B because A is a matching; moreover each edge in A \ B is adjacent to an edge in B \ A by maximality of B, hence

{\displaystyle |A\setminus B|\leq 2|B\setminus A|.}{\displaystyle |A\setminus B|\leq 2|B\setminus A|.}
Further we deduce that

{\displaystyle |A|=|A\cap B|+|A\setminus B|\leq 2|B\cap A|+2|B\setminus A|=2|B|.}|A|=|A\cap B|+|A\setminus B|\leq 2|B\cap A|+2|B\setminus A|=2|B|.
In particular, this shows that any maximal matching is a 2-approximation of a maximum matching and also a 2-approximation of a minimum maximal matching. This inequality is tight: for example, if G is a path with 3 edges and 4 vertices, the size of a minimum maximal matching is 1 and the size of a maximum matching is 2.

A spectral characterization of the matching number of a graph is given by Hassani Monfared and Mallik as follows: Let {\displaystyle G}G be a graph on {\displaystyle n}n vertices, and {\displaystyle \lambda _{1}>\lambda _{2}>\ldots >\lambda _{k}>0}{\displaystyle \lambda _{1}>\lambda _{2}>\ldots >\lambda _{k}>0} be {\displaystyle k}k distinct nonzero purely imaginary numbers where {\displaystyle 2k\leq n}{\displaystyle 2k\leq n}. Then the matching number of {\displaystyle G}G is {\displaystyle k}k if and only if (a) there is a real skew-symmetric matrix {\displaystyle A}A with graph {\displaystyle G}G and eigenvalues {\displaystyle \pm \lambda _{1},\pm \lambda _{2},\ldots ,\pm \lambda _{k}}{\displaystyle \pm \lambda _{1},\pm \lambda _{2},\ldots ,\pm \lambda _{k}} and {\displaystyle n-2k}{\displaystyle n-2k} zeros, and (b) all real skew-symmetric matrices with graph {\displaystyle G}G have at most {\displaystyle 2k}2k nonzero eigenvalues.[6] Note that the (simple) graph of a real symmetric or skew-symmetric matrix {\displaystyle A}A of order {\displaystyle n}n has {\displaystyle n}n vertices and edges given by the nonozero off-diagonal entries of {\displaystyle A}A.

3 Matching polynomials

Main article: Matching polynomial
A generating function of the number of k-edge matchings in a graph is called a matching polynomial. Let G be a graph and mk be the number of k-edge matchings. One matching polynomial of G is

{\displaystyle \sum {k\geq 0}m{k}x^{k}.}\sum {k\geq 0}m{k}x^{k}.
Another definition gives the matching polynomial as

{\displaystyle \sum _{k\geq 0}(-1){k}m_{k}x{n-2k},}\sum _{k\geq 0}(-1){k}m_{k}x{n-2k},
where n is the number of vertices in the graph. Each type has its uses; for more information see the article on matching polynomials.

4 Algorithms and computational complexity

4.1 Maximum-cardinality matching

4.2 Maximum-weight matching

4.3 Maximal matchings

4.4 Counting problems

4.5 Finding all maximally-matchable edges

4.6 Online bipartite matching

5 Characterizations

6 Applications

6.1 Matching in general graphs

6.2 Matching in bipartite graphs

7 See also

### 解决 PP-OCRv4 出现的错误 当遇到 `WARNING: The pretrained params backbone.blocks2.0.dw_conv.lab.scale not in model` 这样的警告时,这通常意味着预训练模型中的某些参数未能匹配到当前配置下的模型结构中[^2]。 对于此问题的一个有效解决方案是采用特定配置文件来适配预训练权重。具体操作方法如下: 通过指定配置文件 `ch_PP-OCRv4_det_student.yml` 并利用已有的最佳精度预训练模型 (`best_accuracy`) 来启动训练过程可以绕过上述不兼容的问题。执行命令如下所示: ```bash python3 tools/train.py -c configs/det/ch_PP-OCRv4/ch_PP-OCRv4_det_student.yml ``` 该方案不仅解决了参数缺失带来的警告,还能够继续基于高质量的预训练成果进行微调,从而提升最终检测效果。 关于蒸馏的概念,在机器学习领域内指的是将大型复杂网络(teacher 模型)的知识迁移到小型简单网络(student 模型)。这里 student 和 teacher 的关系是指两个不同规模或架构的神经网络之间的指导与被指导的关系;其中 teacher 已经经过充分训练并具有良好的性能,而 student 则试图模仿前者的行为模式以达到相似的效果但保持更高效的计算特性。 至于提到的 `Traceback` 错误信息部分,由于未提供具体的跟踪堆栈详情,难以给出针对性建议。不过一般而言,这报错往往涉及代码逻辑错误或是环境配置不当等问题。为了更好地帮助定位和解决问题,推荐记录完整的异常日志,并仔细检查最近修改过的代码片段以及确认依赖库版本的一致性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值