Assign each edge a real benefit . A maximum-weight matching maximizes over all matchings in a graph ; the empty matching in a graph is allowed. Setting every recovers a maximum cardinality matching, but otherwise the objectives can disagree.
On the same path graph , give the middle edge benefit and each outer edge benefit . The matching in a graph has total benefit , while the two-edge matching in a graph has total benefit . Thus the smaller choice is the unique maximum-weight matching. If instead the requirement is to find a maximum cardinality matching and then maximize benefit among those, the outer edges must be chosen. Requiring a perfect matching before optimizing cost is another distinct problem, covered by minimum-weight perfect matching. With negative benefits a maximum-weight matching can even be empty, so it need not be a maximal matching.
For a finite graph without an isolated vertex and with nonnegative edge weights, put and let attain this minimum. Define savings and baseline . A maximum-weight matching with weights , allowing arbitrary cardinality, gives a minimum-weight edge coverIt replaces separate cheapest coverage of two endpoints by a shared edge when doing so saves enough weight. Savings can be negative even though original costs are nonnegative; such edges need not be selected.
Proof. The construction covers all vertices. Duplicate selected edges are counted once, so nonnegative weights give . Take an optimal edge cover and delete redundant edges to make it inclusion-minimal without increasing cost. Its components are star graphs, by the argument for the edge cover and matching identity. Select one edge from each component to obtain a matching in a graph . A component with center , selected leaf and other leaves contributes to , at most its total edge weight since . Thus . Maximizing giveswhich proves both the construction and the displayed identity, including zero-weight cases. One call to a general-graph maximum-weight matching polynomial-time algorithm suffices, together with linear-time preprocessing. Choosing a maximum cardinality matching under these modified weights would impose an unnecessary constraint and can spoil the reduction.[ref]
Maximum-weight matching documentation by NetworkX. max_weight_matching, maxcardinality=False, and Notes on polynomial running time
For nonnegative weights on a finite graph, scan edges in nonincreasing weight order, selecting each when it shares no endpoint with an already selected edge. This greedy matching is a factor-two approximation algorithm for maximum-weight matching.
Proof. Charge each optimal edge to itself if selected, and otherwise to an earlier selected edge that blocked it. The receiving edge weighs at least as much. Each selected edge receives at most two charges, since its two endpoints each meet at most one optimal edge. Summing proves the bound. Sorting takes time, followed by a scan that records which vertices are used.
The factor is sharp even for strictly positive weights. On a four-vertex path graph with consecutive weights , where , the greedy matching weighs and the optimal matching in a graph weighs two. Their ratio tends to two as . For infinitely many sizes, use disjoint copies with , . This example isolates the obstruction: a locally attractive edge can block two compatible edges.
Articles by others on the same topic
Maximum weight matching is a concept from graph theory, specifically in the context of bipartite graphs and weighted graphs. It refers to an optimal assignment problem where the goal is to find a matching that maximizes the total weight associated with the matched edges. ### Definitions: - **Matching**: A matching in a graph is a set of edges such that no two edges share a vertex. In a matching, each vertex is connected to at most one edge.