Maximum matches: the number of matching edges that match the maximum
Minimum point coverage: Select a minimum point so that at least one end of any edge is selected
Maximum independent number: Select the most points so that any selected two points are not connected
Minimum path coverage: For a DAG (directed acyclic graph), select the fewest paths so that each vertex belongs to and belongs to only one path. The path length can be 0 (that is, a single point).
Theorem 1: Maximum number of matches = minimum point coverage (this is the Konig theorem)
Theorem 2: Maximum number of matches = maximum Independent number
Theorem 3: Minimum path coverage = number of vertices-maximum number of matches
const int n=555;///The maximum number of bool Tu[n][n];int from[n];///records to the right of the point if it is paired well where it comes from bool use[n];///record to the right of the point whether it has completed pairing int n,m;///m, n represents the respective number of sides, N is the left, M is the right bool Dfs (int x) { for (int i=1;i<=m;i++)///m is the right, so the upper bound is M if (!use[i]&&tu[x] [i]) { use[i]=1; if (from[i]==-1| | DFS (From[i])) { from[i]=x; return 1; } } return 0;} int Hungary () { int tot=0; Memset (From,-1,sizeof (from)); for (int i=1;i<=n;i++)///n is left, so here the upper bound is n { memset (use,0,sizeof (use)); if (Dfs (i)) tot++; } return tot;}
can also be changed into vector version, the method is more flexible.
Binary Chart Hungarian algorithm template