Maximum Matching Bipartite Graph
Maximum Matching Bipartite Graph
Bipartite graph
• A bipartite graph separates the V vertices {1, 2, 3, a, b, c} into two distinct set of vertices,
V1 with subset {1, 2, 3}, and V2 with subset {a, b, c}.
1 a
2 b
3 c
Bipartite Matching
Matching is defined as connection the pair of vertices from two distinct set of vertices.
Property
• Bipartite Matching is Matching in a bipartite graph where each edge has unique endpoints
(vertex), i.e., no two edges share the same vertex.
E.g.,
• Let consider M employees and N jobs. Each employee is capable of performing some job.
Each employee is assigned job during the matching process.
1 a
2 b
3 c
• A matching in a graph is a subset of its edges with the property
that no two edges share a vertex.
• A maximum matching— a maximum cardinality matching—is a
matching with the largest number of edges.
• The maximum-matching problem is the problem of finding a
maximum matching in a given graph.
• In a bipartite graph, all the vertices can be partitioned into two
disjoint sets V and U , not necessarily of the same size, so that
every edge connects a vertex in one of these sets to a vertex in the
other set.
• A graph is bipartite if its vertices can be colored in two colors so
that every edge has its vertices colored in different colors; such
graphs are also said to be 2-colorable.
Maximum Bipartite Matching
A B
C D
Unweighted Bipartite Matching
Definitions
Matching
Free Vertex
Definitions
A B C D E
1 2 3 4 5
Maximum Matching Problem
Solution: Find the free vertices
• X= {A, B, C, D, E}
• Y = { 1,2, 3, 4, 5}; The free vertices in X are A, B, C
The free vertices in Y are 1,2,5
• Given M= { (D,3), (E,4)}
• Let consider the node A. 𝑀𝑎 = {(A,1), (D,3), (E,4)}
A B C D E
1 2 3 4 5
Maximum Matching Problem
• 𝑀𝑎 = {(A,1), (D,3), (E,4)}.
• Let consider the node B. 𝑀𝑏 = (A,1), (D,3), (E,4), (B, 1). But, it is adjacent
edge to the (A,1) i.e., vertex 1 is shared by A and B. It is not satisfy the
property.
• So, update the matching as (A, 2), & (B, 1).
A B C D E
1 2 3 4 5
Maximum Matching Problem
• 𝑀𝑎={(A,1), (D,3), (E,4)}.
• Let consider the node B. 𝑀𝑏 = {(A,1), (D,3), (E,4), (B, 1)}. But, it is adjacent edge to the
(A,1)
• i.e., vertex 1 is shared by A and B. It is not satisfy the property.
• So, update the matching as (A, 2), & (B, 1).
• 𝑀𝑏 = {(D,3), (E,4), (A, 2), (B, 1)}.
A B C D E
1 2 3 4 5
Maximum Matching Problem
• 𝑀𝑏={(D,3), (E,4), (A, 2), (B, 1)}.
• Let consider the node C. (C,1) is not feasible. Check (C, 3). But, it is adjacent edge to the (D,
3) i.e., vertex 3 is shared by D. So, remove this match. Add the new match (C, 3).
• 𝑀𝑐 = {(E,4), (A, 2), (B, 1), (C, 3)}.
A B C D E
1 2 3 4 5
Maximum Matching Problem
• 𝑀𝑐={(E,4), (A, 2), (B, 1), (C, 3)}.
• Let consider the node D. (D, 4) is not feasible. But, it is adjacent edge to the (E, 4) i.e.,
vertex 4 is shared by E. Check (D, 5). Add the new match (D, 5).
• 𝑀𝑑 = {(E,4), (A, 2), (B, 1), (C, 3), (D, 5)}.
A B C D E
1 2 3 4 5
Maximum Matching Problem
• 𝑀𝑑 = {(E,4), (A, 2), (B, 1), (C, 3), (D, 5)}.
• Let consider the node E. (E, 4) is feasible.
• 𝑀𝑑 = {(E,4), (A, 2), (B, 1), (C, 3), (D, 5)}.
A B C D E
1 2 3 4 5
• Matching Md is not only a maximum matching but also perfect, i.e., a matching that matches
all the vertices of the graph.
Overall algorithm
1.
A B C D E
1 2 3 4 5
Answer
A B C D E
1 2 3 4 5
Time analysis