1.
Combinatorial Algorithms(Algorithms in Bipartite Graphs)
2.
IntroductionAlgorithms in unweighted bipartite graphMaximum matchingA simple algorithmHopcroft-Karp algorithmOutline
3.
DefinitionA graph G = (V, E) is bipartite if there exists partitionV = X Y∪ with X Y =∩ ∅ and E X × Y⊆ .Bipartite Graph typesUnweightedWeightedFor every edge e E∈ , there is aweight w(e) .Introduction
4.
Example:There are a set of boys and a set of girls.Each boy only likes girls and each girl only likes boys.A common friend wants to match each boy with a girl such thatthe boy and girl are both happy – but they both will only behappy if the boy likes the girl and the girl likes the boy.Is it possible for every situation?IntroductionWe can use a bipartite graphto model this problem
7.
DefinitionMatchingA Matching is a subset M E⊆ such that ∀v V∈ at most oneedge in M is incident upon v– Maximum matching– A Maximum Matching is matching M such that everyothermatching M′ satisfies |M′| ≤ |M|.– Unweighted graph: |M|= the number of edges– Weighted graph: |M|=– Perfect Matching– A matching which matches all vertices of the graphMaximum matching
8.
A Matching A Maximum MatchingNot a MatchingDefinitionWe say that a vertex is matched if it is incident to some edge inM.Otherwise, the vertex is freematchedfree(not perfect)Maximum matching
9.
DefinitionAlternating PathsA path is alternating if its edges alternatebetween M and E − M.Augmenting PathsAn alternating path is augmenting if bothendpoints are freeAlternating TreeA tree rooted at some free vertex v inwhich every path is an alternating path.• Alternating paths( Y1, X2, Y2, X4 )• Augmenting Path(Y1, X2, Y2, X4, Y4, X5)Maximum matching
10.
Property of Augmenting PathsReplacing the M edges by the E − M ones increments size of thematching(Path: Y1, X2, Y2, X4, Y4,X5)Berges Theorem: A matching M is maximum iff ithas no augmenting path (Proof: Lec01 Page 3)Maximum matching
11.
A simple algorithmX2X3X1Y1Y2 Y3 Y4 Maximum matching
15.
A simple algorithm• Commonly search algorithm (BFS, DFS) O(E)• At most V times• Complexity: O(VE)X2X3X1Y1Y2 Y3 Y4 Maximum matching
16.
Hopcroft-Karp AlgorithmAn algorithm to find the maximum matching given abipartite graphGordon
17.
Introduction• The Hopcroft-Karp algorithm was published in1973• It is a matching algorithm that finds amaximum matching in bipartite graphs• The main idea is to augment along a set ofvertex-disjoint shortest augment pathssimulatenously• The complexity is O(√|V||E|)• In this section, some Theorems and Lemmasfrom graph theory will be stated withoutshowing the proof.
18.
Definition• We let the set A B denote the symmetric⊕difference of the set• A B = (A B) – (A B)⊕ ∪ ∩• A maximal set of vertex-disjoint minimumlength augmenting path is defined as follows : It is a set of augmenting path No two path share a same vertex If the minimum length augmenting path is oflength k, then all paths in S are of length k If p is an augmenting path not in S, then pshares a vertex with some path p’ in S
19.
AlgorithmThe algorithm of Hopcroft and Kraft is as follows :Given a graph G = (X Y),E)∪1) Let M = {} ,2) Find S = {P1 , P2 , … Pk}3) While S ≠ {}M = M S⊕Find S4) Output M
20.
Demonstration of algorithm at some stageLet the dark edges represent the edgesin a matching M
21.
Demonstration of algorithm at some stagePink edges represent anaugmenting pathDeleting them
22.
Demonstration of algorithm at some stageAnother augmenting pathNo more paths
23.
Demonstration of algorithm at some stagePink edges represent thepaths in maximal set SM S⊕Note the before and after