Graph Matching: Shmuel Wimer
Graph Matching: Shmuel Wimer
Graph Matching: Shmuel Wimer
Given a matching , an -alternating path is alternating
between edges in and edges not in .
Let ’s end vertices be not in . Replacement of ’s edges
with produces a matching such that , called
-augmentation.
March 2020 Graph Matching 3
Maximum matching has no augmentation path. (why?)
Symmetric Difference:
𝐺
(𝑉 , 𝐸 )
𝐺 𝐻
(𝑉 ,𝐸 )
𝐻
∆ 𝐻 ≜ 𝐹(𝑉 ,𝐸 ⊕ 𝐸 )
𝐺 𝐺 𝐻
Symmetric difference is used also for matching.
If and are two matchings then .
𝑌
Denote the neighbors in of . is clearly necessary for a
matching saturating .
March 2020 Graph Matching 6
Theorem. (Hall 1935) If is bipartite then has a
bipartition matching saturating iff for all .
Proof. Sufficiency. Let be maximum and for each ,
there is . Let be not saturated. There exists therefore ,
not -saturated.
We will find contradicting the theorem’s hypothesis.
𝑋
𝑆 𝑢
𝑌 𝑇 =𝑁 (𝑆)
The paths reach by edges not in M and by ’s edges.
Since is maximum, there is no -augmentation paths, so
every vertex of is -saturated.
Every extends via to a vertex in . Also, is reached by
from , thus .
March 2020 Graph Matching 8
The matching between and implies .
In fact, . If there was an edge from to a vertex , it could
not be in , yielding an alternating path to ,
contradicting is maximum.
Therefore, , which is a contradiction of the theorem’s
hypothesis. ■
Consider an arbitrary . The number of edges
connecting to is and those edges are incident to .
The total number of edges incident to is . There is
therefore .
We thus obtained , satisfying Hall’s Theorem sufficient
condition . ■
March 2020 Graph Matching 11
Min-Max Dual Theorems
Can something be said on whether a matching is
maximum when a complete matching does not exist?
Exploring all alternating paths to find whether or not
there is an -augmentation is expensive.
Let be a minimum cover. We subsequently construct a
matching from such that .
Let and . Two bipartite subgraphs and are induced by
and , respectively.
It is impossible to have an edge connecting with .
Otherwise, would not be a cover. Hence the matchings
in and are disjoint.
𝑈
𝑋
𝑅
’
𝐻
𝑌
𝑇
Let and consider . If we could replace by in and obtain
a smaller vertex cover, contradicting being minimum.
Therefore and Hall’s Theorem conditions hold in . has
therefore a complete matching of into .
Same arguments
hold for ’. ■
We will also prove that for every bipartite graph
(without isolated vertices) .
Lemma. is an independent set iff is a vertex cover, and
hence ().
Proof. Let be a maximum matching (). We can use it to
construct an edge cover of by adding an edge incident
to each of the unsaturated vertices, yielding edge cover
of size .
The smallest edge cover is a lower bound. Therefore, .
x1
𝑈
x
⊂x
𝑋 x4 x5 x6 x1
𝑆=𝑈
x x x4 x5 x6
2 3 2 3
𝑀
y1 y2 y3 y4 y5 y6
𝑇
y1 y2 y3 y4 y5 y6
March 2020 Graph Matching 23
𝑈 ⊂𝑋
x1 x2 x3 x4 x5 x6
End of iteration.
New augmented matching.
y1 y2 y3 y4 y5 y6
x1 x2 x3 x4 x5 x6
𝑆
No augmentation found.
Max matching found.
𝑇y
y2 y3 y4 y5 y6
1
Initialization: , .
Iteration: If all is marked stop: is a maximum matching
and is a minimum cover.
Otherwise, select unmarked . Consider each such that .
If is unsaturated an -ugmentation path from to exists.
Augment .
Otherwise, is matched by with some . In that case add
to and to .
March 2020 Graph Matching 25
After exploring all edges incident to , mark and iterate.
■
Theorem. Repeated application of the Augmenting Path
Algorithm to a bipartite graph produces matching and a
cover of the same size.
Proof. Consider upon termination.
-alternating path from enters only via ’s edges, hence
there is a matching between and .
An -alternating path traverses from into along any
-unsaturated edge, thus .
The government will pay the company to stop farm
production and to stop plant manufacturing.
If the company will not take the offer and and will
continue working.
March 2020 Graph Matching 28
What should the government offer to completely stop
the farms and plants ?
It must offer for all . The government also wishes to
minimize .
Definitions. Given an matrix , a transversal is a
selection of entries, one for each row and one for each
column.
Finding a transversal of with maximum weight sum is
called the assignment problem, a matrix formulation of
the maximum weighted matching problem, where we
seek a perfect matching maximizing .
March 2020 Graph Matching 29
The labels and cover the weights if for all .
The minimum weighted cover problem is to find a
cover minimizing the cost .
The maximum weighted matching and the minimum
weighted cover problems are dual.
If equality must hold for each of the summand.
Finally, since is bounded by , equality implies that both
must be optimal. ■
March 2020 Graph Matching 31
Weighted Bipartite Matching Algorithm
The relation between maximum weighted matching and
edge covered by equalities lends itself to an algorithm,
named the Hungarian Algorithm.
It combines -augmentation path with cover trimming.
Denote by the subgraph of spanned by the edges
satisfying .
The algorithm ensures that if has a perfect matching
(in , its weight is and by the lemma both matching and
cover are optimal.
Otherwise, the algorithm modifies the cover.
March 2020 Graph Matching 32
Algorithm. (Kuhn 1955, Munkres 1957)
Input: Bipartition and weights of .
Idea: Maintain a cover , iteratively reducing its cost, until
the equality graph has a perfect matching.
Initialization: Define a feasible labeling , and . Find a
maximum matching in (apply path augmentation to ).
Iteration: If is perfect in stop. is a maximum weight
matching by the lemma.
Else, let be the -unsaturated in and , and be reached
from by -alternating paths.
March 2020 Graph Matching 33
𝑈
𝑆− 𝜀 in
𝑋
𝜀
𝑌
𝑇 +𝜀
Let
Decrease by for all and increase by for all .
Derive a new equality graph . If it contains an
-augmentation path, replace by a maximum matching in
.
Iterate anyway. ■
March 2020 Graph Matching 34
𝑢 4 8 6
𝑢 4 8 6
𝑋
𝑋 𝑈
6 1 6 1
4 4
1 6 8 1 6 8
𝑌
𝑌
𝑣 0 0 0
𝑣 0 𝑀
0 𝐺𝑢 , 𝑣
0
𝑢 4 8 6
𝑋
𝑆
6 1 Minimum surplus from to :
4
1 6 8
𝑌
𝑀
𝑇
𝑣 0 0 𝐺𝑢 , 𝑣 0
March 2020 Graph Matching 35
𝑢 4 6 4
𝑢 4 6 4
𝑋
𝑋
6 1 6 1
4 4
1 6 8 1 6 8
𝑌
𝑌
𝑣 0 2 0
𝑣 0 𝐺 ′𝑢 , 𝑣
2 𝑀
0
which is a maximum in is a perfect matching in and
therefore it is maximum weight matching.
To validate, the total edge weight is 16, same as the
total cover.
Consider the numbers , obtained from the cover , after
decreasing and increasing by . If and , then and cover
holds.
March 2020 Graph Matching 37
If and , then and cover holds.
If and , then , hence cover holds.
Finally, if and , then . Since was the smallest surplus
from to , cover holds.
is stable.
March 2020 Graph Matching 40
Gale and Shapley proved that a stable matching always
exists and can be found by a simple algorithm.
Algorithm. (Gale-Shapley Proposal Algorithm).
Input: Preference ranking by each of men and women.
odd
𝐺
odd odd
𝑀
𝑀
𝑀
𝐺−𝑆
even
𝑆 even
At most vertices of can be matched by with those of .
𝑀
𝑀
𝑈
At least odd components must have a vertex not
covered by , hence , for any .
𝐺
𝑆
Does have a perfect matching ?
, whereas , hence .
Claim. If it happens that for some matching and there is
, then is a maximum matching. (homework)
¿𝑈 ∨≥2
is maximum
since .
𝑼
𝑴
The proof of the opposite direction is more complex.
Tutte’s condition is preserved under edge addition,
namely, if , so it is for .
March 2020 Graph Matching 52
That follows since edge addition may merge two
components into one, hence .
Proof plan. We will consider a graph possessing Tutte’s
condition and assume in contrary that it has no 1-factor,
but the addition of any edge obtains 1-factor.
We then add two edge and construct a 1-factor in . We
then remove and show the existence of 1-factor in ,
hence a contradiction.
must be even. That follows by taking , so , hence no odd
component could exist.
March 2020 Graph Matching 53
Let be such that is connected to all s vertices and
suppose that consists of disjoint cliques.
𝐺 −𝑈
odd clique
𝑈
even clique
vertices are arbitrarily paired up, with the leftover
residing in the odd components. Since , the leftover ones
matched to any of .
March 2020 Graph Matching 54
is a clique of its own, hence all its rest vertices (even)
are paired up and 1-factor in exists.
We must therefore consider for the contradiction
establishment that is not made all of cliques.
There must be non-adjacent vertices sharing a
common vertex (otherwise are in a clique, or is an
independent set).
Since , there is , non adjacent to .
March 2020 Graph Matching 55
Recall that was chosen to be maximal not having 1-
factor, such that the addition of any edge will turn it to
possess 1-factor.
Let and be the 1-factors in and , respectively. By
maximality and .
It suffices to show that has 1-factor avoiding and , in
contradiction with the maximality of .
Consider with the edges of . There is .
Since the degree of any ’s vertex in and is exactly one
(perfect matchings), has only isolated vertices and
disjoint even cycles.
Here is a matching of 𝑀
2 𝑥 𝑀
1 𝑧 𝑀
2
avoiding both and .
Outside either or 𝑀
2
𝑦 𝑤
D1
FF
Q1 CL D2
FF
Q2
clk_g
clk_g
D3
Latch Q3
A
clk
To minimize gating overhead, FFs are grouped in -size
sets for joint clock gating.
March 2020 Graph Matching 58
: FF group size (to optimize), : FF’s probability for .
𝐶 latch
𝑘
𝐶 save ≥𝑞 ( 𝐶 FF+𝐶 wire ) − [𝑘
+ ( 1− 𝑞 ) ( 𝐶 wire +𝑐 OR ) ]
Derivate by :
Let and be the toggling vectors of and , .
If , minimizing the redundant clock pulses turns to
finding min cost matching in weighted .
March 2020 Graph Matching 61
FF 𝑗
‖a 𝑖 ⊕ a 𝑗‖
FF𝑖
Optimal FF pairing () is solved in polynomial time by
minimal cost perfect matching.
March 2020 Graph Matching 62
Example: 8 FFs, 13 cycles min cost matching. Redundant
CLK occurs at 0.
a 𝑘 ∨a𝑙
a 𝑖∨a 𝑗
FF𝑖
FF𝑘 FF 𝑗
FF𝑙
Optimal -grouping is NP-hard
Solution. If has no perfect matching, let be a largest
(maximum) possible matching.
Let . Since is not perfect and , there are at least two
unmatched vertices and edge does not exist.
Consider how and can be connected. Assume there
are at least 3 edges involved.
𝑥
𝑦
𝑥
𝑦
There are 2 independent edges which can be used for
matching if is removed, contradicting that is a largest
matching.
Consequently, cannot be both connected to any of the
vertices involved in , which number is at most .
Consequently, .
But , hence a contradiction.
March 2020 Graph Matching 67
Problem Denote by the size of the largest independent
set of . Show that the vertices of a graph can be
covered by no more than vertex-disjoint paths.
𝑉𝑖
𝑉 𝑖+1
𝑉𝑖
𝑉 𝑖+1
consists of vertex-disjoint paths covering , except
vertices of .
Taking these as one-point paths, we obtain vertex-
disjoint paths covering
March 2020 Graph Matching 71