通过选择具有最少边数的顶点来实现最大匹配的贪婪算法?

问题描述

我正在学习 Blossom 算法,但我很困惑为什么您不能简单地执行我想到的这种贪婪方法。有人有反例吗?

While no more vertices:
    Choose the vertex (V) with the least number of edges
    Considering vertices connected to that vertex V,choose one with the least number of edges.
    Create this edge and don't consider these two vertices anymore. 
    Reduce the count of edges on each vertex accordingly. Repeat

解决方法

input = input.to(device)

如果第一步你选择BC,你就输了,因为你剩下2个奇数周期,你不能覆盖所有的顶点。最优匹配为AB CD EF GH。