ACS 7101/3 – Advanced Algorithm Design. Finding the maximum matching of a bipartite graph. Final Project. November 2008. Finding the maximum matching of a bipartite graph. From an initial matching. We want to find the maximum matching. 1 2 3 4 5 6.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
ACS 7101/3 – Advanced Algorithm Design
Finding the maximum matching of a bipartite graph
Final Project
November 2008
Finding the maximum matching of a bipartite graph
From an initial matching
We want to find the maximum matching
1 2 3 4 5 6
1 2 3 4 5 6
7 8 9 10 11 12
7 8 9 10 11 12
Notes:
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
The general procedure is:
M1G1G1’PM1 P = M2
M2G2G2’P1 & P2 M2 P1 P2 = M3
In this example M3 is the maximum matching
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
We start with the graph stored in a text file as pairs u, v
Store the file in memory using an Array of Objects
Graph.txt
1 7
2 8
2 9
3 9
3 10
4 10
11
…
…
1 2 3 4 5 6
7 8 9 10 11 12
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
M1G1
G1
G1 is a directed graph
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
G1G1’ : finding j*
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
G1’P
1 2 3 4 5 6
7 8 9 10 11 12
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
PM1 P = M2
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
PM2 P1 = M3
Idea behind the symmetric difference:
3 edges in the path:
(1, 7)
(7, 6)
(6, 12)
1 2 3 4 5 6
1 2 3 4 5 6
M2
P1
7 8 9 10 11 12
7 8 9 10 11 12
Edge (1, 7)
In M2 doesn’t belong to a match match
(A[1].M = 0 AND A[7].M = 1)
M3
1 2 3 4 5 6
7 8 9 10 11 12
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
PM2 P1 = M3
Idea behind the symmetric difference:
3 edges in the path:
(1, 7)
(7, 6)
(6, 12)
1 2 3 4 5 6
1 2 3 4 5 6
M2
P1
7 8 9 10 11 12
7 8 9 10 11 12
Edge (1, 7)
In M2 doesn’t belong to a match match
(A[1].M = 0 AND A[7].M = 1)
M3
1 2 3 4 5 6
7 8 9 10 11 12
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
PM2 P1 = M3
Idea behind the symmetric difference:
3 edges in the path:
(1, 7)
(7, 6)
(6, 12)
1 2 3 4 5 6
1 2 3 4 5 6
M2
P1
7 8 9 10 11 12
7 8 9 10 11 12
Edge (7, 6)
Is a matching in M2 ignore
(A[7].M = 1 AND A[6].M = 1)
M3
1 2 3 4 5 6
7 8 9 10 11 12
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
PM2 P1 = M3
Idea behind the symmetric difference:
3 edges in the path:
(1, 7)
(7, 6)
(6, 12)
1 2 3 4 5 6
1 2 3 4 5 6
M2
P1
7 8 9 10 11 12
7 8 9 10 11 12
Edge (6, 12)
In M2 doesn’t belong to a match match
(A[6].M = 1 AND A[12].M = 0)
M3
1 2 3 4 5 6
7 8 9 10 11 12
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
PM2 P1 = M3
How does the code work:
We only evaluate alternate edges
Edge (1, 7)
In M2 doesn’t belong to a match match
(A[1].M = 0 AND A[7].M = 1)
A[1].M = 1 AND A[7].M = 1
…
…
…
Edge (6, 12)
In M2 doesn’t belong to a match match
(A[6].M = 1 AND A[12].M = 0)
A[6].M = 1 AND A[12].M = 1
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
PM2 P1 = M3
After repeating the process:
M3
1 2 3 4 5 6
7 8 9 10 11 12
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
writeGraph.txt
1 7 Match
2 8 Match
2 9
3 9
3 10 Match
…
7 1 Match
6
2 Match
…
The final step is to write al the pairs (u, v) back into a text file including the matching edges found
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
List of files coded:
main.cpp
linkedListBG.h
graph.txt
array.cpp
readFile.cpp
display.cpp
randomMatching.cpp
exampleMatching.cpp
findLevels.cpp
findPaths.cpp
writeFile.cpp
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
Improvements to be done before testing it with bigger graphs:
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
Problems encounter during the process:
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
Positive actions during the process :
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
What is next:
ACS 7101 – Advance Data Structures
November 2008
Finding the maximum matching of a bipartite graph
Questions?
ACS 7101 – Advance Data Structures
November 2008