SlideShare a Scribd company logo
Maximum Matching in General Graphs

                                          Ahmad Khayyat
                            Department of Electrical & Computer Engineering
                                   ahmad.khayyat@ece.queensu.ca

                                            Course Project
                                 CISC 879 — Algorithms and Applications
                                           Queen’s University


                                        November 19, 2008



ECE @ Queen’s • Fall 2008                     Ahmad Khayyat        Maximum Matching in General Graphs • 1
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion




 Outline


        1       Introduction

        2       Paths, Trees and Flowers

        3       Efficient Implementation of Edmonds’ Algorithm

        4       Reachability Problem Approach

        5       Conclusion




ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 2
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion




 Outline

        1       Introduction
                   Terminology
                   Berge’s Theorem
                   Bipartite Matching

        2       Paths, Trees and Flowers

        3       Efficient Implementation of Edmonds’ Algorithm

        4       Reachability Problem Approach

        5       Conclusion

ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 3
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 Terminology


 Maximum Matching

                G = (V, E) is a finite undirected graph: n = |V |, m = |E|.
                A matching M in G, (G, M ), is a subset of its edges such
                that no two meet the same vertex.
                M is a maximum matching if no other matching in G
                contains more edges than M .
                A maximum matching is not necessarily unique.
                Given (G, M ), a vertex is exposed if it meets no edge in M .


                                               M




ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 4
Introduction         Paths, Trees and Flowers        Efficient Implementation    Reachability Approach      Conclusion

 Terminology


 Augmenting Paths


                An alternating path in (G, M ) is a simple path whose edges
                are alternately in M and not in M .
                An augmenting path is an alternating path whose ends are
                distinct exposed vertices.

                         v1            v2             v3                  v1        v2            v3


                 v6             v5               v4                 v6         v5          v4




ECE @ Queen’s • Fall 2008                              Ahmad Khayyat            Maximum Matching in General Graphs • 5
Introduction       Paths, Trees and Flowers        Efficient Implementation      Reachability Approach      Conclusion

 Berge’s Theorem


 Berge’s Theorem

        Berge’s Theorem (1957)
        A matched graph (G, M ) has an augmenting path if and only if M
        is not maximum.

                   v1            v2            v3                       v1         v2            v3


            v6              v5          v4                       v6           v5          v4
                                                                             Unique?
        An Exponential Algorithm:
        Exhaustively search for an augmenting path starting from an
        exposed vertex.

ECE @ Queen’s • Fall 2008                            Ahmad Khayyat              Maximum Matching in General Graphs • 6
Introduction         Paths, Trees and Flowers   Efficient Implementation       Reachability Approach      Conclusion

 Bipartite Matching


 Bipartite Graphs

                A bipartite graph G = (A, B, E) is a graph whose vertices can
                be divided into two disjoint sets A and B such that every
                edge connects a vertex in A to one in B.
                Equivalently, it is a graph with no odd cycles.

                         1           A

                                     C                        1                                 C

                         4           D                                    A          4          D
                                                              2
                         2           E                                                          E
                                                                          B          5
                         3           B                        3
                         5


ECE @ Queen’s • Fall 2008                         Ahmad Khayyat               Maximum Matching in General Graphs • 7
Introduction         Paths, Trees and Flowers       Efficient Implementation   Reachability Approach      Conclusion

 Bipartite Matching


 Bipartite Graph Maximum Matching

                             for all v ∈ A, v is exposed do
                               Search for simple alternating paths starting at v
                               if path P ends at an exposed vertex u ∈ B then
    O(nm)                         P is an augmenting path {Update M }
                               end if
                             end for
                             Current M is maximum {No more augmenting paths}
            1                                    C

                         A           4           D
            2
                                                 E
                         B           5
            3


ECE @ Queen’s • Fall 2008                             Ahmad Khayyat           Maximum Matching in General Graphs • 8
Introduction         Paths, Trees and Flowers       Efficient Implementation   Reachability Approach       Conclusion

 Bipartite Matching


 Bipartite Graph Maximum Matching

                             for all v ∈ A, v is exposed do
                               Search for simple alternating paths starting at v
                               if path P ends at an exposed vertex u ∈ B then
    O(nm)                         P is an augmenting path {Update M }
                               end if
                             end for
                             Current M is maximum {No more augmenting paths}
            1                                    C                       1                            C

                         A           4           D                             A           4          D
            2                                                            2
                                                 E                                                    E
                         B           5                                         B           5
            3                                                            3


ECE @ Queen’s • Fall 2008                             Ahmad Khayyat           Maximum Matching in General Graphs • 8
Introduction         Paths, Trees and Flowers       Efficient Implementation          Reachability Approach      Conclusion

 Bipartite Matching


 Non-Bipartite Matching

        Problem: Odd cycles . . .

                                                                             4           6
                                   1             2              3
                                                                             5



                                             1              2            3

                                                     6                           4
                                                                    5


ECE @ Queen’s • Fall 2008                                Ahmad Khayyat               Maximum Matching in General Graphs • 9
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion




 Outline


        1       Introduction

        2       Paths, Trees and Flowers
                  Blossoms
                  The Algorithm

        3       Efficient Implementation of Edmonds’ Algorithm

        4       Reachability Problem Approach

        5       Conclusion


ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 10
Introduction       Paths, Trees and Flowers       Efficient Implementation          Reachability Approach      Conclusion

 Blossoms


 Blossoms
        Blossoms
        A blossom B in (G, M ) is an odd cycle with a unique exposed
        vertex (the base) in M ∩ B.

                                                                           4           6
                                 1             2              3
                                                                           5

                                           1              2            3

                                                   6                           4
                                                                  5

ECE @ Queen’s • Fall 2008                              Ahmad Khayyat               Maximum Matching in General Graphs • 11
Introduction       Paths, Trees and Flowers       Efficient Implementation   Reachability Approach      Conclusion

 Blossoms


 Edmonds’ Blossoms Lemma

        Blossoms Lemma
        Let G and M be obtained by contracting a blossom B in (G, M )
        to a single vertex.
        The matching M of G is maximum iff M is maximum in G .

                                                                       4        6
                                 1             2            3
                                                                       5

                                       1            2            B          6


ECE @ Queen’s • Fall 2008                           Ahmad Khayyat           Maximum Matching in General Graphs • 12
Introduction       Paths, Trees and Flowers       Efficient Implementation   Reachability Approach      Conclusion

 Blossoms


 Detecting Blossoms

                Performing the alternating path search of the bipartite
                matching algorithm (starting from an exposed vertex):
                   ´   Label vertices at even distance from the root as “outer”;
                   ´   Label vertices at odd distance from the root as “inner”.
                If two outer vertices are found adjacent, we have a blossom.

                                                                        I

                                 O             I            O
                                                                       4        6
                                 1             2            3
                                                                       5
                                                                       O




ECE @ Queen’s • Fall 2008                           Ahmad Khayyat           Maximum Matching in General Graphs • 13
Introduction       Paths, Trees and Flowers      Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Edmonds’ Algorithm (1965)

                    for all v ∈ V , v is exposed do
                      Search for simple alternating paths starting at v
      O(n3 ) O(n2 )
                          Shrink any found blossoms
                      if path P ends at an exposed vertex then
                         P is an augmenting path {Update M }
                      else if no augmenting paths found then
                         Ignore v in future searches
                      end if
                    end for
                    Current M is maximum {No more augmenting paths}


                                               Complexity: O(n4 )

ECE @ Queen’s • Fall 2008                          Ahmad Khayyat           Maximum Matching in General Graphs • 14
Introduction       Paths, Trees and Flowers        Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4


                              1                2          3             4


                                               10         9             5       6


                                                          8             7




ECE @ Queen’s • Fall 2008                            Ahmad Khayyat           Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers        Efficient Implementation       Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4
                              O                I          O             I
                              1                2          3             4

                                                                             O
                                               10         9             5           6    I




                                                          8             7
                                                                        O




ECE @ Queen’s • Fall 2008                            Ahmad Khayyat               Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers        Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4
                              O                I          O             I
                              1                2          3             4


                                               10         9           B1
                                                                        O


                                                          8


        B1 = 5, 6, 7


ECE @ Queen’s • Fall 2008                            Ahmad Khayyat           Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers        Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4
                              O                I          O             I
                              1                2          3             4

                                                          O
                                               10         9           B1
                                                                        O


                                                          8
                                                          I


        B1 = 5, 6, 7


ECE @ Queen’s • Fall 2008                            Ahmad Khayyat           Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers        Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4
                              O                I          O             I
                              1                2          3             4


                                               10        B2
                                               I          O




        B1 = 5, 6, 7
        B2 = B1 , 8, 9 = 5, 6, 7, 8, 9

ECE @ Queen’s • Fall 2008                            Ahmad Khayyat           Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers        Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4


                              1                2          3             4


                                               10        B2




        B1 = 5, 6, 7
        B2 = B1 , 8, 9 = 5, 6, 7, 8, 9

ECE @ Queen’s • Fall 2008                            Ahmad Khayyat           Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers        Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4


                              1                2          3             4


                                               10         9           B1


                                                          8


        B1 = 5, 6, 7
        B2 = B1 , 8, 9 = 5, 6, 7, 8, 9

ECE @ Queen’s • Fall 2008                            Ahmad Khayyat           Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers        Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Example

        |M | = 4                                                                                |M | = 5


                              1                2          3             4


                                               10         9             5       6


                                                          8             7


        B1 = 5, 6, 7
        B2 = B1 , 8, 9 = 5, 6, 7, 8, 9

ECE @ Queen’s • Fall 2008                            Ahmad Khayyat           Maximum Matching in General Graphs • 15
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion




 Outline

        1       Introduction

        2       Paths, Trees and Flowers

        3       Efficient Implementation of Edmonds’ Algorithm
                 Data Structures
                 The Algorithm
                 Performance

        4       Reachability Problem Approach

        5       Conclusion

ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 16
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 Data Structures


 Three Arrays
                u is an exposed vertex.
                A vertex v is outer if there is a path P (v) = (v, v1 , . . . , u),
                where vv1 ∈ M .

           1    MATE: Specifies a matching. An entry for each vertex:
                   ´   vw ∈ M ⇒ MATE (v) = w and MATE (w) = v.
           2    LABEL: Provides a type and a value:
                                LABEL(v) ≥ 0                    → v is outer
                                LABEL(u)                        → start label, P (u) = (u)
                            1 ≤ LABEL(v) ≤ n                    → vertex label
                   n + 1 ≤ LABEL(v) ≤ n + 2m → edge label

           3    START (v) = the first non-outer vertex in P (v).

ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 17
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Gabow’s Algorithm (1976)
                            for all u ∈ V, u is exposed do
                              while ∃ an edge xy, x is outer AND
                                      no augmenting path found do
                                 if y is exposed, y = u then
                                    (y, x, . . . , u) is an augmenting path
                                 else if y is outer then
                                    Assign edge labels to P (x) and P (y)
                                 else if MATE (y) is non-outer then
                                    Assign a vertex label to MATE (y)
                                 end if
                              end while
                            end for



ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 18
Introduction       Paths, Trees and Flowers      Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Gabow’s Algorithm (1976)
         O(n)          for all u ∈ V, u is exposed do
                         while ∃ an edge xy, x is outer AND
                                 no augmenting path found do
                 O(1)       if y is exposed, y = u then
                    O(n)       (y, x, . . . , u) is an augmenting path
                 O(n)       else if y is outer then
                    O(n)       Assign edge labels to P (x) and P (y)
                 O(n)       else if MATE (y) is non-outer then
                     O(1)      Assign a vertex label to MATE (y)
                            end if
                         end while
                       end for

                                               Complexity: O(n3 )

ECE @ Queen’s • Fall 2008                          Ahmad Khayyat           Maximum Matching in General Graphs • 18
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 Performance


 Experimental Performance



        Using an implementation in Algol W on the IBM 360/165
            Worst-case graphs:
                   ´   Efficient Implementation: run times proportional to n2.8 .
                   ´   Edmond: run times proportional to n3.5 .
                Random graphs: times one order of magnitude faster than
                worst-case graphs.
                Space used is 5n + 4m.




ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 19
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion




 Outline


        1       Introduction

        2       Paths, Trees and Flowers

        3       Efficient Implementation of Edmonds’ Algorithm

        4       Reachability Problem Approach
                  Reachability and Graphs
                  The Algorithm

        5       Conclusion


ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 20
Introduction        Paths, Trees and Flowers    Efficient Implementation        Reachability Approach       Conclusion

 Reachability and Graphs


 The Reachability Problem in Bipartite Graphs
                Construction:
                       Bipartite graph + Matching → Directed graph
                       G = (A, B, E) +     M      → G = (V , E )
                   ´   V = V ∪ {s, t}
                   ´   ∀ xy ∈ M , x ∈ A, y ∈ B → (x, y) ∈ E                         e∈M ⇒e:A→B
                   ´   ∀ xy ∈ M , x ∈ A, y ∈ B → (y, x) ∈ E
                            /                                                       e∈M ⇒e:B→A
                                                                                     /
                   ´   ∀ b ∈ B, b is exposed → add (s, b) to E
                   ´   ∀ a ∈ A, a is exposed → add (a, t) to E

                     A1             B1                                    A1          B1
                                                =⇒          t                                          s

                     A2             B2                                    A2          B2



ECE @ Queen’s • Fall 2008                            Ahmad Khayyat             Maximum Matching in General Graphs • 21
Introduction        Paths, Trees and Flowers    Efficient Implementation        Reachability Approach       Conclusion

 Reachability and Graphs


 The Reachability Problem in Bipartite Graphs
                Construction:
                       Bipartite graph + Matching → Directed graph
                       G = (A, B, E) +     M      → G = (V , E )
                   ´   V = V ∪ {s, t}
                   ´   ∀ xy ∈ M , x ∈ A, y ∈ B → (x, y) ∈ E                         e∈M ⇒e:A→B
                   ´   ∀ xy ∈ M , x ∈ A, y ∈ B → (y, x) ∈ E
                            /                                                       e∈M ⇒e:B→A
                                                                                     /
                   ´   ∀ b ∈ B, b is exposed → add (s, b) to E
                   ´   ∀ a ∈ A, a is exposed → add (a, t) to E

                     A1             B1                                    A1          B1
                                                =⇒          t                                          s

                     A2             B2                                    A2          B2

                An augmenting path in G ⇔ A simple path from s to t in G .
ECE @ Queen’s • Fall 2008                            Ahmad Khayyat             Maximum Matching in General Graphs • 21
Introduction        Paths, Trees and Flowers        Efficient Implementation       Reachability Approach       Conclusion

 Reachability and Graphs

 The Reachability Problem in General Graphs
 Construction

                For each v ∈ V , we introduce two nodes vA and vB
                            V = {vA , vB |v ∈ V } ∪ {s, t}                        s, t ∈ V, s = t
                                                                                       /
                e ∈ M ⇒ e : A → B,                        e∈M ⇒e:B→A
                                                           /
                    E =          {(xA , yB ), (yA , xB ) | (x, y) ∈ M }
                              ∪ {(xB , yA ), (yB , xA ) | (x, y) ∈ M }
                                                                 /
                              ∪ {(s, xB ) | x is exposed} ∪ {(xA , t) | x is exposed}
                                                                              t
                   1               2                     1A            2A            3A             4A
                                                =⇒
                                                        1B             2B            3B            4B
                   4               3
                                                                              s

ECE @ Queen’s • Fall 2008                             Ahmad Khayyat                Maximum Matching in General Graphs • 22
Introduction        Paths, Trees and Flowers        Efficient Implementation       Reachability Approach      Conclusion

 Reachability and Graphs

 The Reachability Problem in General Graphs
 Strongly Simple Paths

        A path P in G is strongly simple if:
            P is simple.
            vA ∈ P ⇒ vB ∈ P .
                          /
        Theorem
        There is an augmenting path in G if and only if there is a strongly
        simple path from s to t in G .

                                                                              t
                   1               2                     1A            2A           3A              4A
                                                =⇒
                                                        1B             2B           3B             4B
                   4               3
                                                                              s

ECE @ Queen’s • Fall 2008                             Ahmad Khayyat               Maximum Matching in General Graphs • 23
Introduction        Paths, Trees and Flowers        Efficient Implementation       Reachability Approach      Conclusion

 Reachability and Graphs


 Solving the Reachability Problem
        Solution: A strongly simple path from s to t in G :
            Depth-First Search (DFS) for t starting at s.
            DFS finds simple paths.
            We need to find strongly simple paths only.
            We use a Modified Depth-First Search (MDFS) algorithm.
        Example:

                                                                              t
                   1               2                     1A            2A           3A              4A
                                                =⇒
                                                        1B             2B           3B             4B
                   4               3
                                                                              s


ECE @ Queen’s • Fall 2008                             Ahmad Khayyat               Maximum Matching in General Graphs • 24
Introduction        Paths, Trees and Flowers        Efficient Implementation       Reachability Approach      Conclusion

 Reachability and Graphs


 Solving the Reachability Problem
        Solution: A strongly simple path from s to t in G :
            Depth-First Search (DFS) for t starting at s.
            DFS finds simple paths.
            We need to find strongly simple paths only.
            We use a Modified Depth-First Search (MDFS) algorithm.
        Example:

                                                                              t
                   1               2                     1A            2A           3A              4A
                                                =⇒
                                                        1B             2B           3B             4B
                   4               3
                                                                              s


ECE @ Queen’s • Fall 2008                             Ahmad Khayyat               Maximum Matching in General Graphs • 24
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Data Structures


                 Stack K
                   ´   TOP(K): the last vertex added to the stack K.
                   ´   Vertices in K form the current path.
                   ´   In each step, the MDFS algorithm considers an edge
                       (TOP(K), v), v ∈ V .


                 List L(vA )
                   ´ To get a strongly simple path, vA and vB cannot be in K
                     simultaneously (we may ignore a vertex, temporarily).
                   ´ List L(vA ) keeps track of such vertices.




ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 25
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm


 Hopcroft and Karp Algorithm for Bipartite Graphs (1973)
        Step 1:    M ←φ
        Step 2:    Let l(M ) be the length of a shortest augmenting path of M
                   Find a maximal set of paths {Q1 , Q2 , . . . , Qt } such that:
                    2.1 For each i, Qi is an augmenting path of M , |Qi | = l(M ),
                        Qi are vertex-disjoint.
                    2.2 Halt if no such paths exists.
        Step 3:    M ← M ⊕ Q1 ⊕ Q2 ⊕ · · · ⊕ Qt ; Go to 1.

        Hopcroft and Karp Theorem
        If the cardinality of a maximum matching is s, then this algorithm
                                                 √
        constructs a maximum matching within 2 s + 2 executions of
        Step 2.

                                                                 √
                 Step 2 complexity: O(m) ⇒ Overall complexity: O( nm)

ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 26
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 The Algorithm
      √
 An O( nm) Algorithm for General Graphs


                 Blum describes an O(m) implementation of Step 2 for general
                 graphs, using a Modified Breadth-First Search (MBFS).
                 Blum’s Step 2 Algorithm:
            Step 1: Using MBFS, compute G
            Step 2: Using MDFS, compute a maximal set of strongly simple paths
                       from s to t in G .

        Blum’s Theorm
        A maximum matching in a general graph can be found in time
           √
        O( nm) and space O(m + n).




ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 27
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion




 Outline


        1       Introduction

        2       Paths, Trees and Flowers

        3       Efficient Implementation of Edmonds’ Algorithm

        4       Reachability Problem Approach

        5       Conclusion
                  Summary
                  Questions


ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 28
Introduction            Paths, Trees and Flowers   Efficient Implementation               Reachability Approach        Conclusion

 Summary


 Summary



                                                                                                                      O(n2.5 )
         O(n4 )                                     O(n3 )           O(n2.5 )                                     O(n2.5 )

           1965                                      1976              1980                                1989     1990     1991
           Ed




                                                      Ga




                                                                       M




                                                                                                                 Va
                                                                                                                 Bl iran
                                                                                                                 Ga
                                                                            ica




                                                                                                                   um i’s
                m




                                                                                                                    z
                                                        bo




                                                                                                                    bo
                on




                                                                             li
                                                          w’




                                                                                                                      w
                                                                                  &
                    ds




                                                            s
                                                             Im




                                                                                  Va




                                                                                                                          Pr
                                                                pl




                                                                                     z




                                                                                                                             oo
                                                                                      ira
                                                                  em




                                                                                                                               f
                                                                                         ni
                                                                     en
                                                                        t
                                                                       at
                                                                        io
                                                                          n




ECE @ Queen’s • Fall 2008                            Ahmad Khayyat                       Maximum Matching in General Graphs • 29
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 Summary


 References

                Jack Edmonds
                Paths, Trees, and Flowers
                Canadian Journal of Mathematics, 17:449–467, 1965.
                http://www.cs.berkeley.edu/~christos/classics/edmonds.ps

                Harold N. Gabow
                An Efficient Implementation of Edmonds’ Algorithm for
                Maximum Matching on Graphs
                Journal of the ACM (JACM), 23(2):221–234, 1976.

                Norbert Blum
                A New Approach to Maximum Matching in General Graphs
                Lecture Notes in Computer Science: Automata, Languages and Programming,
                443::586–597, Springer Berlin / Heidelberg, 1990.



ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 30
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 Summary


 Thank You




                                      Thank You!



ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 31
Introduction       Paths, Trees and Flowers   Efficient Implementation   Reachability Approach      Conclusion

 Questions


 Questions




                                                 ???



ECE @ Queen’s • Fall 2008                       Ahmad Khayyat           Maximum Matching in General Graphs • 32
Ad

More Related Content

What's hot (20)

Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
JorgeVillamarin5
 
5.5 graph mining
5.5 graph mining5.5 graph mining
5.5 graph mining
Krish_ver2
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
hodcsencet
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Amit Kumar Rathi
 
Amortized Analysis of Algorithms
Amortized Analysis of Algorithms Amortized Analysis of Algorithms
Amortized Analysis of Algorithms
sathish sak
 
All pair shortest path
All pair shortest pathAll pair shortest path
All pair shortest path
Arafat Hossan
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
 
lattice
 lattice lattice
lattice
Daffodil International University
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
Jenny Galino
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
Abhishek Singh
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
Dr Sandeep Kumar Poonia
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
Respa Peter
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
Amit Kumar Rathi
 
Graph algorithm
Graph algorithmGraph algorithm
Graph algorithm
University of Potsdam
 
The Maximum Subarray Problem
The Maximum Subarray ProblemThe Maximum Subarray Problem
The Maximum Subarray Problem
Kamran Ashraf
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
Dr. C.V. Suresh Babu
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
Dr Shashikant Athawale
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Graph Theory: Cut-Set and Cut-Vertices
Graph Theory: Cut-Set and Cut-VerticesGraph Theory: Cut-Set and Cut-Vertices
Graph Theory: Cut-Set and Cut-Vertices
Ashikur Rahman
 

Viewers also liked (14)

Simple algorithm & hopcroft karp for bipartite graph
Simple algorithm & hopcroft karp for bipartite graphSimple algorithm & hopcroft karp for bipartite graph
Simple algorithm & hopcroft karp for bipartite graph
Miguel Pereira
 
Fahroo - Optimization and Discrete Mathematics - Spring Review 2013
Fahroo - Optimization and Discrete Mathematics - Spring Review 2013Fahroo - Optimization and Discrete Mathematics - Spring Review 2013
Fahroo - Optimization and Discrete Mathematics - Spring Review 2013
The Air Force Office of Scientific Research
 
Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...
Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...
Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...
Kostas Katrinis
 
DFA minimization algorithms in map reduce
DFA minimization algorithms in map reduceDFA minimization algorithms in map reduce
DFA minimization algorithms in map reduce
Iraj Hedayati
 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimization
guest5873b2d
 
DFA Minimization in Map-Reduce
DFA Minimization in Map-ReduceDFA Minimization in Map-Reduce
DFA Minimization in Map-Reduce
Iraj Hedayati
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20
Kumar
 
Network flow problems
Network flow problemsNetwork flow problems
Network flow problems
Dr Sandeep Kumar Poonia
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
Maulik Togadiya
 
Hearn - Optimization and Discrete Mathematics - Spring Review 2012
Hearn - Optimization and Discrete Mathematics - Spring Review 2012Hearn - Optimization and Discrete Mathematics - Spring Review 2012
Hearn - Optimization and Discrete Mathematics - Spring Review 2012
The Air Force Office of Scientific Research
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
Tech_MX
 
Parallel Algorithms for Trees
Parallel Algorithms for TreesParallel Algorithms for Trees
Parallel Algorithms for Trees
Ahmad Khayyat
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
Huawei Technologies
 
Backtracking
BacktrackingBacktracking
Backtracking
subhradeep mitra
 
Simple algorithm & hopcroft karp for bipartite graph
Simple algorithm & hopcroft karp for bipartite graphSimple algorithm & hopcroft karp for bipartite graph
Simple algorithm & hopcroft karp for bipartite graph
Miguel Pereira
 
Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...
Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...
Teaching Graph Algorithms in the Field - Bipartite Matching in optical datace...
Kostas Katrinis
 
DFA minimization algorithms in map reduce
DFA minimization algorithms in map reduceDFA minimization algorithms in map reduce
DFA minimization algorithms in map reduce
Iraj Hedayati
 
DFA Minimization in Map-Reduce
DFA Minimization in Map-ReduceDFA Minimization in Map-Reduce
DFA Minimization in Map-Reduce
Iraj Hedayati
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20
Kumar
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
Tech_MX
 
Parallel Algorithms for Trees
Parallel Algorithms for TreesParallel Algorithms for Trees
Parallel Algorithms for Trees
Ahmad Khayyat
 
Ad

Recently uploaded (20)

PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
Dastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptxDastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptx
omorfaruqkazi
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
The History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.pptThe History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.ppt
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdfGENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
Quiz Club of PSG College of Arts & Science
 
Conditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture SlideConditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture Slide
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
Quiz Club of PSG College of Arts & Science
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
PUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for HealthPUBH1000 Slides - Module 12: Advocacy for Health
PUBH1000 Slides - Module 12: Advocacy for Health
JonathanHallett4
 
Dastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptxDastur_ul_Amal under Jahangir Key Features.pptx
Dastur_ul_Amal under Jahangir Key Features.pptx
omorfaruqkazi
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptxU3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
U3 ANTITUBERCULAR DRUGS Pharmacology 3.pptx
Mayuri Chavan
 
Ad

Maximum Matching in General Graphs

  • 1. Maximum Matching in General Graphs Ahmad Khayyat Department of Electrical & Computer Engineering ahmad.khayyat@ece.queensu.ca Course Project CISC 879 — Algorithms and Applications Queen’s University November 19, 2008 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 1
  • 2. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Outline 1 Introduction 2 Paths, Trees and Flowers 3 Efficient Implementation of Edmonds’ Algorithm 4 Reachability Problem Approach 5 Conclusion ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 2
  • 3. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Outline 1 Introduction Terminology Berge’s Theorem Bipartite Matching 2 Paths, Trees and Flowers 3 Efficient Implementation of Edmonds’ Algorithm 4 Reachability Problem Approach 5 Conclusion ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 3
  • 4. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Terminology Maximum Matching G = (V, E) is a finite undirected graph: n = |V |, m = |E|. A matching M in G, (G, M ), is a subset of its edges such that no two meet the same vertex. M is a maximum matching if no other matching in G contains more edges than M . A maximum matching is not necessarily unique. Given (G, M ), a vertex is exposed if it meets no edge in M . M ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 4
  • 5. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Terminology Augmenting Paths An alternating path in (G, M ) is a simple path whose edges are alternately in M and not in M . An augmenting path is an alternating path whose ends are distinct exposed vertices. v1 v2 v3 v1 v2 v3 v6 v5 v4 v6 v5 v4 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 5
  • 6. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Berge’s Theorem Berge’s Theorem Berge’s Theorem (1957) A matched graph (G, M ) has an augmenting path if and only if M is not maximum. v1 v2 v3 v1 v2 v3 v6 v5 v4 v6 v5 v4 Unique? An Exponential Algorithm: Exhaustively search for an augmenting path starting from an exposed vertex. ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 6
  • 7. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Bipartite Matching Bipartite Graphs A bipartite graph G = (A, B, E) is a graph whose vertices can be divided into two disjoint sets A and B such that every edge connects a vertex in A to one in B. Equivalently, it is a graph with no odd cycles. 1 A C 1 C 4 D A 4 D 2 2 E E B 5 3 B 3 5 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 7
  • 8. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Bipartite Matching Bipartite Graph Maximum Matching for all v ∈ A, v is exposed do Search for simple alternating paths starting at v if path P ends at an exposed vertex u ∈ B then O(nm) P is an augmenting path {Update M } end if end for Current M is maximum {No more augmenting paths} 1 C A 4 D 2 E B 5 3 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 8
  • 9. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Bipartite Matching Bipartite Graph Maximum Matching for all v ∈ A, v is exposed do Search for simple alternating paths starting at v if path P ends at an exposed vertex u ∈ B then O(nm) P is an augmenting path {Update M } end if end for Current M is maximum {No more augmenting paths} 1 C 1 C A 4 D A 4 D 2 2 E E B 5 B 5 3 3 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 8
  • 10. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Bipartite Matching Non-Bipartite Matching Problem: Odd cycles . . . 4 6 1 2 3 5 1 2 3 6 4 5 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 9
  • 11. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Outline 1 Introduction 2 Paths, Trees and Flowers Blossoms The Algorithm 3 Efficient Implementation of Edmonds’ Algorithm 4 Reachability Problem Approach 5 Conclusion ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 10
  • 12. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Blossoms Blossoms Blossoms A blossom B in (G, M ) is an odd cycle with a unique exposed vertex (the base) in M ∩ B. 4 6 1 2 3 5 1 2 3 6 4 5 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 11
  • 13. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Blossoms Edmonds’ Blossoms Lemma Blossoms Lemma Let G and M be obtained by contracting a blossom B in (G, M ) to a single vertex. The matching M of G is maximum iff M is maximum in G . 4 6 1 2 3 5 1 2 B 6 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 12
  • 14. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Blossoms Detecting Blossoms Performing the alternating path search of the bipartite matching algorithm (starting from an exposed vertex): ´ Label vertices at even distance from the root as “outer”; ´ Label vertices at odd distance from the root as “inner”. If two outer vertices are found adjacent, we have a blossom. I O I O 4 6 1 2 3 5 O ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 13
  • 15. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Edmonds’ Algorithm (1965) for all v ∈ V , v is exposed do Search for simple alternating paths starting at v O(n3 ) O(n2 ) Shrink any found blossoms if path P ends at an exposed vertex then P is an augmenting path {Update M } else if no augmenting paths found then Ignore v in future searches end if end for Current M is maximum {No more augmenting paths} Complexity: O(n4 ) ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 14
  • 16. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 1 2 3 4 10 9 5 6 8 7 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 17. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 O I O I 1 2 3 4 O 10 9 5 6 I 8 7 O ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 18. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 O I O I 1 2 3 4 10 9 B1 O 8 B1 = 5, 6, 7 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 19. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 O I O I 1 2 3 4 O 10 9 B1 O 8 I B1 = 5, 6, 7 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 20. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 O I O I 1 2 3 4 10 B2 I O B1 = 5, 6, 7 B2 = B1 , 8, 9 = 5, 6, 7, 8, 9 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 21. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 1 2 3 4 10 B2 B1 = 5, 6, 7 B2 = B1 , 8, 9 = 5, 6, 7, 8, 9 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 22. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 1 2 3 4 10 9 B1 8 B1 = 5, 6, 7 B2 = B1 , 8, 9 = 5, 6, 7, 8, 9 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 23. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Example |M | = 4 |M | = 5 1 2 3 4 10 9 5 6 8 7 B1 = 5, 6, 7 B2 = B1 , 8, 9 = 5, 6, 7, 8, 9 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 15
  • 24. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Outline 1 Introduction 2 Paths, Trees and Flowers 3 Efficient Implementation of Edmonds’ Algorithm Data Structures The Algorithm Performance 4 Reachability Problem Approach 5 Conclusion ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 16
  • 25. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Data Structures Three Arrays u is an exposed vertex. A vertex v is outer if there is a path P (v) = (v, v1 , . . . , u), where vv1 ∈ M . 1 MATE: Specifies a matching. An entry for each vertex: ´ vw ∈ M ⇒ MATE (v) = w and MATE (w) = v. 2 LABEL: Provides a type and a value: LABEL(v) ≥ 0 → v is outer LABEL(u) → start label, P (u) = (u) 1 ≤ LABEL(v) ≤ n → vertex label n + 1 ≤ LABEL(v) ≤ n + 2m → edge label 3 START (v) = the first non-outer vertex in P (v). ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 17
  • 26. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Gabow’s Algorithm (1976) for all u ∈ V, u is exposed do while ∃ an edge xy, x is outer AND no augmenting path found do if y is exposed, y = u then (y, x, . . . , u) is an augmenting path else if y is outer then Assign edge labels to P (x) and P (y) else if MATE (y) is non-outer then Assign a vertex label to MATE (y) end if end while end for ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 18
  • 27. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Gabow’s Algorithm (1976) O(n) for all u ∈ V, u is exposed do while ∃ an edge xy, x is outer AND no augmenting path found do O(1) if y is exposed, y = u then O(n) (y, x, . . . , u) is an augmenting path O(n) else if y is outer then O(n) Assign edge labels to P (x) and P (y) O(n) else if MATE (y) is non-outer then O(1) Assign a vertex label to MATE (y) end if end while end for Complexity: O(n3 ) ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 18
  • 28. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Performance Experimental Performance Using an implementation in Algol W on the IBM 360/165 Worst-case graphs: ´ Efficient Implementation: run times proportional to n2.8 . ´ Edmond: run times proportional to n3.5 . Random graphs: times one order of magnitude faster than worst-case graphs. Space used is 5n + 4m. ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 19
  • 29. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Outline 1 Introduction 2 Paths, Trees and Flowers 3 Efficient Implementation of Edmonds’ Algorithm 4 Reachability Problem Approach Reachability and Graphs The Algorithm 5 Conclusion ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 20
  • 30. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Reachability and Graphs The Reachability Problem in Bipartite Graphs Construction: Bipartite graph + Matching → Directed graph G = (A, B, E) + M → G = (V , E ) ´ V = V ∪ {s, t} ´ ∀ xy ∈ M , x ∈ A, y ∈ B → (x, y) ∈ E e∈M ⇒e:A→B ´ ∀ xy ∈ M , x ∈ A, y ∈ B → (y, x) ∈ E / e∈M ⇒e:B→A / ´ ∀ b ∈ B, b is exposed → add (s, b) to E ´ ∀ a ∈ A, a is exposed → add (a, t) to E A1 B1 A1 B1 =⇒ t s A2 B2 A2 B2 ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 21
  • 31. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Reachability and Graphs The Reachability Problem in Bipartite Graphs Construction: Bipartite graph + Matching → Directed graph G = (A, B, E) + M → G = (V , E ) ´ V = V ∪ {s, t} ´ ∀ xy ∈ M , x ∈ A, y ∈ B → (x, y) ∈ E e∈M ⇒e:A→B ´ ∀ xy ∈ M , x ∈ A, y ∈ B → (y, x) ∈ E / e∈M ⇒e:B→A / ´ ∀ b ∈ B, b is exposed → add (s, b) to E ´ ∀ a ∈ A, a is exposed → add (a, t) to E A1 B1 A1 B1 =⇒ t s A2 B2 A2 B2 An augmenting path in G ⇔ A simple path from s to t in G . ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 21
  • 32. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Reachability and Graphs The Reachability Problem in General Graphs Construction For each v ∈ V , we introduce two nodes vA and vB V = {vA , vB |v ∈ V } ∪ {s, t} s, t ∈ V, s = t / e ∈ M ⇒ e : A → B, e∈M ⇒e:B→A / E = {(xA , yB ), (yA , xB ) | (x, y) ∈ M } ∪ {(xB , yA ), (yB , xA ) | (x, y) ∈ M } / ∪ {(s, xB ) | x is exposed} ∪ {(xA , t) | x is exposed} t 1 2 1A 2A 3A 4A =⇒ 1B 2B 3B 4B 4 3 s ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 22
  • 33. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Reachability and Graphs The Reachability Problem in General Graphs Strongly Simple Paths A path P in G is strongly simple if: P is simple. vA ∈ P ⇒ vB ∈ P . / Theorem There is an augmenting path in G if and only if there is a strongly simple path from s to t in G . t 1 2 1A 2A 3A 4A =⇒ 1B 2B 3B 4B 4 3 s ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 23
  • 34. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Reachability and Graphs Solving the Reachability Problem Solution: A strongly simple path from s to t in G : Depth-First Search (DFS) for t starting at s. DFS finds simple paths. We need to find strongly simple paths only. We use a Modified Depth-First Search (MDFS) algorithm. Example: t 1 2 1A 2A 3A 4A =⇒ 1B 2B 3B 4B 4 3 s ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 24
  • 35. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Reachability and Graphs Solving the Reachability Problem Solution: A strongly simple path from s to t in G : Depth-First Search (DFS) for t starting at s. DFS finds simple paths. We need to find strongly simple paths only. We use a Modified Depth-First Search (MDFS) algorithm. Example: t 1 2 1A 2A 3A 4A =⇒ 1B 2B 3B 4B 4 3 s ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 24
  • 36. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Data Structures Stack K ´ TOP(K): the last vertex added to the stack K. ´ Vertices in K form the current path. ´ In each step, the MDFS algorithm considers an edge (TOP(K), v), v ∈ V . List L(vA ) ´ To get a strongly simple path, vA and vB cannot be in K simultaneously (we may ignore a vertex, temporarily). ´ List L(vA ) keeps track of such vertices. ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 25
  • 37. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm Hopcroft and Karp Algorithm for Bipartite Graphs (1973) Step 1: M ←φ Step 2: Let l(M ) be the length of a shortest augmenting path of M Find a maximal set of paths {Q1 , Q2 , . . . , Qt } such that: 2.1 For each i, Qi is an augmenting path of M , |Qi | = l(M ), Qi are vertex-disjoint. 2.2 Halt if no such paths exists. Step 3: M ← M ⊕ Q1 ⊕ Q2 ⊕ · · · ⊕ Qt ; Go to 1. Hopcroft and Karp Theorem If the cardinality of a maximum matching is s, then this algorithm √ constructs a maximum matching within 2 s + 2 executions of Step 2. √ Step 2 complexity: O(m) ⇒ Overall complexity: O( nm) ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 26
  • 38. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion The Algorithm √ An O( nm) Algorithm for General Graphs Blum describes an O(m) implementation of Step 2 for general graphs, using a Modified Breadth-First Search (MBFS). Blum’s Step 2 Algorithm: Step 1: Using MBFS, compute G Step 2: Using MDFS, compute a maximal set of strongly simple paths from s to t in G . Blum’s Theorm A maximum matching in a general graph can be found in time √ O( nm) and space O(m + n). ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 27
  • 39. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Outline 1 Introduction 2 Paths, Trees and Flowers 3 Efficient Implementation of Edmonds’ Algorithm 4 Reachability Problem Approach 5 Conclusion Summary Questions ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 28
  • 40. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Summary Summary O(n2.5 ) O(n4 ) O(n3 ) O(n2.5 ) O(n2.5 ) 1965 1976 1980 1989 1990 1991 Ed Ga M Va Bl iran Ga ica um i’s m z bo bo on li w’ w & ds s Im Va Pr pl z oo ira em f ni en t at io n ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 29
  • 41. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Summary References Jack Edmonds Paths, Trees, and Flowers Canadian Journal of Mathematics, 17:449–467, 1965. http://www.cs.berkeley.edu/~christos/classics/edmonds.ps Harold N. Gabow An Efficient Implementation of Edmonds’ Algorithm for Maximum Matching on Graphs Journal of the ACM (JACM), 23(2):221–234, 1976. Norbert Blum A New Approach to Maximum Matching in General Graphs Lecture Notes in Computer Science: Automata, Languages and Programming, 443::586–597, Springer Berlin / Heidelberg, 1990. ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 30
  • 42. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Summary Thank You Thank You! ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 31
  • 43. Introduction Paths, Trees and Flowers Efficient Implementation Reachability Approach Conclusion Questions Questions ??? ECE @ Queen’s • Fall 2008 Ahmad Khayyat Maximum Matching in General Graphs • 32
  翻译: