Lecture 4: Matching Algorithms String Matching Pairwise Matching in Graphs
Knuth-Morris-Pratt Automaton searching for the substring “ababcb”
Knuth-Morris-Pratt Algorithm
Boyer-Moore Algorithm
Boyer-Moore Boyer-Moore searching for the substring “EDGEKIT”.
Bipartite Matching The pairwise matching of members of a bipartite graph is another type of matching. You are searching for a maximal matching (i.e. max number of pairings).
The Augmenting Path Algorithm Given a bipartite graph Gn,m we are to find a maximal matching (max number of pairs) between the n nodes of group I and the m nodes of group II. There is a greedy algorithm for the maximal matching problem:
Augmenting Path: An Example Start with a bipartite graph. Choose arbitrary pairings until no additional matches are possible. In this example nodes C, R and S are not matched. Matching edges are shown in bold
We will now build an augmenting path starting from node S. S-A=P-C. We exchange the matched and unmatched edges in this augmenting path increasing the total number of matches by one. A is matched to S B is matched to Q C is matched to P This is a maximal matching because there are no more unmatched nodes in one of the two groups.
Maximal Matching in a General Graph
For General Graphs The Augmenting Path Algorithm does not necessarily produce a maximal matching in a general graph. In an odd cycle there will be two unmatched edges that share a vertex. The our DFS is started from such a vertex and the cycle is traversed the wrong way we will miss the augmenting path.