KM algorithm summary

Source: Internet
Author: User

"Dichotomy" is a special graph structure, all points are divided into two categories, remember to do X and Y, all the edges of the two ends in X and Y, there is no two sides with the X or Y side.

"Maximum match, complete match"

Given a binary graph (x, y), find a scheme with the largest number of matches, and remember to do the maximum match. |x|=|y|= match number, we call this matching scheme a complete match.

Obviously, solving the maximum match also solves the complete match.

The maximum matching of binary graphs can be solved by network flow or Hungarian algorithm, which is essentially the same, but the Hungarian algorithm is even better in terms of both programming complexity and operational efficiency.

For the Hungarian algorithm, see my previous article: using Hungarian algorithm to find the maximum matching of two-fractal graphs

Here I mainly describe another type of problem:

"Best Complete Match"

There is a right (non-negative) for each edge of the binary graph, which requires a complete matching scheme, which makes the right and maximum of all matching edges and the best complete match. (Special, when the right of all sides is 1 o'clock, is the maximum complete matching problem)

KM algorithm: (full name is Kuhn-munkras, which was presented in 1957 by these two people, interestingly, the Hungarian algorithm was proposed in 1965)

Set up a top mark for each point Li, do not have to control its meaning.

Set Vi,j as (I,j) edge of the right, if you can obtain a complete match, so that each matching edge vi,j=li+lj, the remaining side VI,J≤LI+LJ.

At this time the solution is optimal, because the right and =∑li of the matching edge, the rest of the arbitrary solution of the right and can not be larger than this

Theorem: The edges of all vi,j=li+lj in a binary graph are composed of a sub-graph G, the maximum match in G is obtained by the Hungarian algorithm, and if the match is a complete match, it is the best complete match.

(I don't know how to prove it)

The problem is, now even Li's meaning is unclear.

In fact, what we are asking for is the value of L, so that the optimal complete match is achieved under the L value.

L Initialize:

LI=MAX{WI,J} (I∈x,j∈y)

Lj=0

Set up the sub-figure G, using the Hungarian algorithm to find the maximum match, if at some point I (i∈x) can not locate the augmented orbit, there is no complete match.

You need to make some adjustments to L at this point:

Set S to find the set of points in X accessed from the augmented orbit from I, T is the set of points in the Access Y.

Found an improved amount dx,dx=min{li+lj-wi,j} (i∈s,j not ∈t)

LI=LI-DX (I∈s)

LI=LI+DX (i∈t)

Repeat the above process and adjust the L continuously until a complete match is obtained.

From the adjustment process can be seen:

New edges are added on top of each adjustment to include all edges in the atom diagram.

After each adjustment ∑li will reduce the DX, because each DX takes the smallest, so to ensure the understanding of the optimality.

Analysis of Complexity:

Set m as the number of edges, from an open point in X to find the complexity of the augmented orbit is the worst O (m), each adjustment after the addition of at least one edge, the maximum adjustment m times, the complexity of each adjustment is the worst O (m), so the total complexity in the worst case is O (m+m2) =o (m2)

Extended:

According to the essence of the KM algorithm, we can find the right and the minimum matching scheme for all matching edges.

L Initialize:

LI=MIN{WI,J} (I∈x,j∈y)

Lj=0

DX=MIN{WI,J-LI-LJ} (i∈s,j not ∈t)

LI=LI+DX (I∈s)

LI=LI-DX (i∈t)

"Best Bets"

It is similar to the best complete match, but it does not have to be a complete match.

Just a few changes to the KM algorithm are possible:

Convert the original image to a complete dichotomy (m=|x| | y|), add an edge that does not exist in the original image, and set the weight of the edge to 0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.