Content deleted Content added
m Graph (mathematics) is now a disambiguation link; please fix., replaced: graph{{dn|date=January 2016}} → graph using AWB |
Undid revision 1297413102 by United Nations Peace Ambassadors Foundation -UNPAF (talk) that link goes to an Australian magazine |
||
(43 intermediate revisions by 31 users not shown) | |||
Line 1:
{{short description|Algorithm for finding max graph matchings}}
The '''blossom algorithm''' is an [[algorithm]] in [[graph theory]] for constructing [[maximum matching]]s on graphs. The algorithm was developed by [[Jack Edmonds]] in 1961,<ref name = "glimpse">{{Citation▼
▲
| last = Edmonds
| first = Jack
Line 5 ⟶ 7:
| year = 1991
| title = History of Mathematical Programming --- A Collection of Personal Reminiscences
| editor = J.K. Lenstra
| pages =
| publisher = CWI, Amsterdam and North-Holland, Amsterdam
{{cite journal
| doi = 10.4153/CJM-1965-045-4
| author = Edmonds, Jack
| title = Paths, trees, and flowers
| journal =
| volume = 17
| year = 1965
| pages =
| doi-access = free
}}</ref> Given a general [[Graph (discrete mathematics)|graph]] {{math|1=''G'' = (''V'', ''E'')}}, the algorithm finds a matching
The algorithm runs in time {{math|[[Big O notation|''O'']]({{abs|''E''}}{{abs|''V''}}{{sup|2}})}}, where {{math|{{abs|''E''}}}} is the number of [[edge (graph)|edges]] of the graph and {{math|{{abs|''V''}}}} is its number of [[vertex (graph)|vertices]]. A better running time of <math>O( |E| \sqrt{ |V| } )</math> for the same task can be achieved with the much more complex algorithm of Micali and Vazirani.<ref name = "micali">{{cite conference
| author1 = Micali, Silvio▼
| author2 = Vazirani, Vijay▼
| title = An O(V<sup>1/2</sup>E) algorithm for finding maximum matching in general graphs▼
| year = 1980▼
| publisher = IEEE Computer Society Press, New York▼
| pages = 17–27▼
}}</ref>▼
A major reason that the blossom algorithm is important is that it gave the first proof that a maximum-size matching could be found using a polynomial amount of computation time. Another reason is that it led to a [[linear programming]] polyhedral description of the matching [[polytope]], yielding an algorithm for min-''weight'' matching.<ref name = "weighted">
Line 23 ⟶ 36:
| author = Edmonds, Jack
| title = Maximum matching and a polyhedron with 0,1-vertices
| journal = Journal of Research of the National Bureau of Standards Section B
| volume = 69
| year = 1965
| pages = 125–130
| doi = 10.6028/jres.069B.013
| doi-access = free
As elaborated by [[Alexander Schrijver]], further significance of the result comes from the fact that this was the first polytope whose proof of integrality "does not simply follow just from [[total unimodularity]], and its description was a breakthrough in [[polyhedral combinatorics]]."<ref name="schrijver">{{cite book|first=Alexander|last=Schrijver|authorlink=Alexander Schrijver|title=Combinatorial Optimization: Polyhedra and Efficiency|publisher=Springer|series=Algorithms and Combinatorics|volume=24}}</ref>▼
▲ }}</ref>
▲As elaborated by [[Alexander Schrijver]], further significance of the result comes from the fact that this was the first polytope whose proof of integrality "does not simply follow just from [[total unimodularity]], and its description was a breakthrough in [[polyhedral combinatorics]]."<ref
==Augmenting paths==
Given {{math|1=''G'' = (''V'', ''E'')}} and a matching
:<math>M_1 = M \oplus P = ( M \setminus P ) \cup ( P \setminus M )</math>. [[File:Edmonds augmenting path.svg|500px|alt=Augmentation along a path]]
| author1 = Lovász, László
| authorlink1 = László Lovász
Line 44 ⟶ 60:
| year = 1986
| isbn = 963-05-4168-8
}}</ref><ref name
| author = Karp, Richard
| contribution = Edmonds's Non-Bipartite Matching Algorithm
| title = Course Notes. U. C. Berkeley
| url = http://www.cs.berkeley.edu/~karp/greatalgo/lecture05.pdf
| url-status = dead
}}</ref> that a matching ''M'' is maximum if and only if there is no ''M''-augmenting path in ''G''. Hence, either a matching is maximum, or it can be augmented. Thus, starting from an initial matching, we can compute a maximum matching by augmenting the current matching with augmenting paths as long as we can find them, and return whenever no augmenting paths are left. We can formalize the algorithm as follows:▼
| archiveurl = https://web.archive.org/web/20081230183603/http://www.cs.berkeley.edu/~karp/greatalgo/lecture05.pdf
| archivedate = 2008-12-30
▲ }}</ref>
INPUT: Graph ''G'', initial matching ''M'' on ''G''
OUTPUT: maximum matching ''M*'' on ''G''
A1 '''function''' ''find_maximum_matching''(
A2 ''P'' ← ''find_augmenting_path''(
A3 '''if''' ''P'' is non-empty '''then'''
A4
A5 '''else'''
A6
A7 '''end if'''
A8 '''end function'''
Line 66 ⟶ 85:
==Blossoms and contractions==
Given {{math|1=''G'' = (''V'', ''E'')}} and a matching
'''''Finding Blossoms:'''''
We define the '''contracted graph''' ''G’'' as the graph obtained from ''G'' by [[edge contraction|contracting]] every edge of ''B'', and define the '''contracted matching''' ''M’'' as the matching of ''G’'' corresponding to ''M''.▼
* Traverse the graph starting from an exposed vertex.
* Starting from that vertex, label it as an outer vertex {{mvar|'''o'''}}.
* Alternate the labeling between vertices being inner {{mvar|'''i'''}} and outer {{mvar|'''o'''}} such that no two adjacent vertices have the same label.
* If we end up with two adjacent vertices labeled as outer {{mvar|'''o'''}} then we have an odd-length cycle and hence a blossom.
▲
[[File:Edmonds blossom.svg|500px|alt=Example of a blossom]]
{{mvar|G'}}
| author = Tarjan, Robert
| contribution = Sketchy Notes on Edmonds' Incredible Shrinking Blossom Algorithm for General Matching
| title = Course Notes, Department of Computer Science, Princeton University
| url = http://www.cs.dartmouth.edu/~ac/Teach/CS105-Winter05/Handouts/tarjan-blossom.pdf
}}</ref> In more detail:
▲}}</ref> that ''G’'' has an ''M’''-augmenting path [[if and only if|iff]] ''G'' has an ''M''-augmenting path, and that any ''M’''-augmenting path ''P’'' in ''G’'' can be '''lifted''' to an ''M''-augmenting path in ''G'' by undoing the contraction by ''B'' so that the segment of ''P’'' (if any) traversing through ''v<sub>B</sub>'' is replaced by an appropriate segment traversing through ''B''. In more detail:
* if {{mvar|P'
[[File:Edmonds lifting path.svg|500px|alt=Path lifting when {{mvar|P'
* if {{mvar|P'
[[File:Edmonds lifting end point.svg|500px|alt=Path lifting when {{mvar|P'
Thus blossoms can be contracted and search performed in the contracted graphs. This reduction is at the heart of Edmonds' algorithm.
Line 91 ⟶ 116:
==Finding an augmenting path==
The search for an augmenting path uses an auxiliary data structure consisting of a [[forest (graph theory)|forest]]
In each iteration the algorithm either (1) finds an augmenting path, (2) finds a blossom and recurses onto the corresponding contracted graph, or (3) concludes there are no augmenting paths. The auxiliary structure is built by an incremental procedure discussed next.<ref name = "tarjan notes"/>
The construction procedure considers vertices
INPUT: Graph ''G'', matching ''M'' on ''G''
OUTPUT: augmenting path ''P'' in ''G'' or empty path if none found
B01 '''function''' ''find_augmenting_path''(
B02 ''F'' ← empty forest
B03 unmark all vertices and edges in ''G'', mark all edges of ''M''
Line 104 ⟶ 129:
B06 create a singleton tree { ''v'' } and add the tree to ''F''
B07 '''end for'''
B08 '''while''' there is an unmarked vertex ''v'' in ''F'' with ''distance(
B09 '''while''' there exists an unmarked edge ''e'' = { ''v'', ''w'' } '''do'''
B10 '''if''' ''w'' is not in ''F'' '''then'''
Line 111 ⟶ 136:
B12 add edges { ''v'', ''w'' } and { ''w'', ''x'' } to the tree of ''v''
B13 '''else'''
B14 '''if''' ''distance(
// Do nothing.
B15 '''else'''
B16 '''if''' ''root(
// Report an augmenting path in F <math>\cup</math> { ''e'' }.
B17 ''P'' ← path (
B18 '''return''' ''P''
B19 '''else'''
Line 122 ⟶ 147:
B20 ''B'' ← blossom formed by ''e'' and edges on the path ''v'' → ''w'' in ''T''
B21 ''G’, M’'' ← contract ''G'' and ''M'' by ''B''
B22 ''P’'' ← ''find_augmenting_path''(
B23 ''P'' ← lift ''P’'' to ''G''
B24 '''return''' ''P''
Line 140 ⟶ 165:
[[File:forest expansion.png|400px|alt=Forest expansion on line B10]]
Next, it detects a blossom and contracts the graph (lines B20 – B21).
[[File:blossom contraction.png|400px|alt=Blossom contraction on line B21]]
Finally, it locates an augmenting path {{mvar|P′}} in the contracted graph (line B22) and lifts it to the original graph (line B23). Note that the ability of the algorithm to contract blossoms is crucial here; the algorithm cannot find
[[File:path detection.png|400px|alt=Detection of augmenting path {{mvar|P′}} in {{mvar|G′}} on line B17]]
[[File:path lifting.png|400px|alt=Lifting of {{mvar|P′}} to corresponding augmenting path in {{mvar|G}} on line B25]]
===Analysis===
The forest
| author1 = Kenyon, Claire
| author2 = Lovász, László
| authorlink2 = László Lovász
| contribution = Algorithmic Discrete Mathematics
| title = Technical Report CS-TR-251-90, Department of Computer Science, Princeton University
}}</ref>
* a tree
**
** every vertex at an odd distance from the root has exactly two incident edges in
** all paths from
* a forest
** its connected components are alternating trees, and
** every exposed vertex in
Each iteration of the loop starting at line B09 either adds to a tree
▲ | author1 = Micali, Silvio
▲ | author2 = Vazirani, Vijay
▲ | title = An O(V<sup>1/2</sup>E) algorithm for finding maximum matching in general graphs
▲ | conference = 21st Annual Symposium on Foundations of Computer Science,
▲ | year = 1980
▲ | publisher = IEEE Computer Society Press, New York
▲ | pages = 17–27
===Bipartite matching===
===Weighted matching===
The matching problem can be generalized by assigning weights to edges in
| author = Kolmogorov, Vladimir
| title = Blossom V: A new implementation of a minimum cost perfect matching algorithm
Line 192 ⟶ 209:
| pages = 43–67
| year = 2009
| doi = 10.1007/s12532-009-0002-8
▲}}</ref>
}}</ref>
==References==
<references/>
[[Category:Graph algorithms]]
[[Category:Matching (graph theory)]]
|