Binary Graph--A brief description of Hungarian algorithm

Source: Internet
Author: User

Yesterday simulation, there is a high-dimensional universe, two-figure matching is the positive solution, but the two-figure matching a little forget, review.

Binary graph matching is actually a case where there are two sets of elements that can match to try to find the most matches.

Two of the binary graphs can be connected with an array to achieve.

Each element can be connected to the edge, if you want to match the point has been accounted for, let the front and target point matching point to find another can match the point, so that you can connect as many points as possible.

The specific code is as follows:

1 BOOLFind (ll x)2 {3      for(intI=1; i<=numb; i++)//iterate through all the points in another collection4     {5         if(Vis[i] = =0and Mp[x][i])//if a point in another collection has not been traversed, and the two points can match6         {7Vis[i] =1;//Mark8             if(Pri[i] = =0|| Find (Pri[i]))//if the target match point does not match, or a point that has already been matched can be swapped for another point match9             {TenPri[i] =x; One                 return true; A             } -         } -     } the     return false; -}

Note that traversing the elements of the collection in the main function each time the VIS array is zeroed before the next element in Find.

Example: high-dimensional universe, matrix game

Dichotomy--A brief description of the Hungarian algorithm

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.