Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 4: Matching Algorithms

Similar presentations


Presentation on theme: "Lecture 4: Matching Algorithms"— Presentation transcript:

1 Lecture 4: Matching Algorithms
String Matching Pairwise Matching in Graphs

2 Knuth-Morris-Pratt Automaton searching for the substring “ababcb”

3 Knuth-Morris-Pratt Algorithm

4 Boyer-Moore Algorithm

5 Boyer-Moore Boyer-Moore searching for the substring “EDGEKIT”.

6 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).

7 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:

8 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

9 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.

10 Maximal Matching in a General Graph

11 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.


Download ppt "Lecture 4: Matching Algorithms"

Similar presentations


Ads by Google