Title: Matching in bipartite graphs
1Matching in bipartite graphs
- Given non-weighted bipartite graph
initial matching
extending alternating path
not covered node
Algorithm so-called extending alternating
path, we start with a not covered node next
step node from the matching (maybe several
edges) in this case no extending alternating
path result
perfect matching
2Vertex Cover Problem
- In general graphs is NP-hard (best approximation
known - 2-approximation) - In bipartite graphs ? exact algorithm
- (we can for sure find optimal matching with
maximum of edges)
1
2
minimum cardinality matching M
3
OPT minimum vertex cover OPT ?
M Proof we need at least 1 vertex in OPT per
edge in M
3Vertex Cover Problem
- In bipartite graphs
- Maximum matching Minimum vertex cover
- Algorithm (also the proof)
- Pick a node that covers red and blue edge
(redfrom M, bluenot from M) (except - last
case) - such blue edge that has one endpoint not
covered by the matching. If such blue edge does
not exist, we have perfect matching (from that
point on, all nodes are covered by the matching).
Every time we have isolated node, we drop it
4Vertex Cover Problem
- In case of perfect matching ? take one part of
the bipartite graph - In general graphs - not true
- Example
-
minimum cover
maximum matching
5Homework solutions
- Problem 1 Translate node weighted graph G
(G,V,w), where w V ? R, into edge weighted
graph G(V,E,w), w E ? R, then apply Dijkstra
on G.
w2
w1w2
w(e)
w1w3
2
2
e
w1
w3
w6
v1
w4
w5
For any edge evivk ? E we define w(e)1/2
w(vi)w(vk). Then length(v0v1...vn-path in
G)length (v0v1...vn-path in G) 1/2 w(v0) 1/2
w(vn) (v0source, vn sink). The
minimum weight path in G corresponds to a minimum
weight path in G.
6Homework solutions
- Problem 2 For G(V,E,w) we define a bipartite
graph - G (VV,E,w)
v1
v2
v3
V
w(v2) 1
v2
2
2
1
3
3
2
2
3
3
V
3
v3
v1
v1
v2
v3
- For each v ? V define a copy v and an edge
(v,v), where - w(v,v)w(v) (corresponds to a loop in v
in graph G) - Every edge (u,v) ? E replace by 2 edges (u,v)
and (u,v) - with the same weight as (u,v)
- G is bipartite (every edge has 1 end in V,
other in V) - Every path from v1 to vn even
- Every path from v1 to vn (copy of vn) odd
7Homework solutions
- Problem 3
- G(V,E,w). For each v ? V define k copies
v1,v2,..., vk - Then create a directed graph G(V,E,w), where
- VV? V1 ? ... ? Vk , vi1? V1, ....
vjk? Vk
v
u
1
1
For each edge (u,v) ? E define edges (u, v1),
(u1, v2), (u2, v3), ... (u(k-1), vk) with the
same edge weight as (u,v). We look at all paths
from v1(source) to vn(sink) or any copy of vn.
All such paths have at most k edges.
2
2
k
k
k
? k edges shortest paths