### The-Winner's blog

By The-Winner, history, 3 months ago,

Hello, Codeforces!

(Disclaimer: I know very little about flows and matchings)

An interesting idea that I heard at the University recently was a greedy algorithm to find the maximum matching in a bipartite graph. The idea is simple, at each step take the node with the smallest number of unmatched neighbours (I will call it active degree) and match this node with one of its neighbours. Specifficaly match it with the neighbour whose active degree is the smallest. Update the active degree for all neighbours of the 2 nodes. Repeat until you can't match anything.

Noone in class was able to find a counter example, but we also couldn't prove that it is correct (which it likely isn't).

If anyone would be kind enough to provide a counter example / proof / link to some paper / article I would be very thankful.

• +37

 » 3 months ago, # |   +88 Here is a counterexample: Edge list$16$ nodes (numbered $1 - 16$), $25$ edges, nodes $1 - 8$ are on the left, nodes $9 - 16$ are on the right. 1 9 1 10 2 9 2 11 2 12 3 11 3 12 3 13 4 11 4 12 4 13 5 11 5 12 5 13 6 10 6 14 6 15 6 16 7 10 7 14 7 15 7 16 8 14 8 15 8 16  Picture ExplanationYou can get a perfect matching by matching everything "horizontally", except for pairs $(1, 10)$ and $(2, 9)$.Your greedy algorithm will first choose the edge $(1, 9)$, since nodes $1$ and $9$ are the only ones with degree $2$.After choosing this, nodes $2, 3, 4, 5$ only have nodes $11, 12, 13$ to pair up with so we can't pair all of nodes $2, 3, 4, 5$ and thus, we won't get a perfect matching.
•  » » 3 months ago, # ^ |   +16 Thank you very much, sir