3
Finding the most weight vertex- weighted matchings Given a bipartite graph G. For each vertex of the first part was not her weight. Required to find the maximum weight matching, ie with the largest sum of the weights of saturated peaks. Below we describe and prove the algorithm based on the algorithm Kuhn , who will be the best solution. Algorithm The algorithm is extremely simple. Sort the top of the first part, in descending order (more precisely, non-increasing) weights, and apply to the resulting graph algorithm Kuhn . It is alleged that obtained with the maximum (in terms of number of edges) and a matching is optimal in terms of sums of weights saturated vertices (despite the fact that we actually sorting after longer use these weights). Thus, the implementation will be something like this: int n; vector <vector <int>> g (n); vector used (n); vector <int> order (n); // Vertex list, sorted by weight ... Reading ... for (int i = 0; i <n; ++ i) { int v = order [i]; used.assign (n, false); try_kuhn (v); } Function try_kuhn () is taken without any changes from the algorithm Kuhn. Proof Recall the basic provisions of the theory of matroids . Matroid M - is an ordered pair (S, I), where S - the a lot of, I - a non-empty family of subsets of S, which satisfy the following conditions:

Finding the Most Weight Vertex-weighted Matchings

Embed Size (px)

DESCRIPTION

Algorithm, Most Weight Vertex-weighted

Citation preview

Finding the most weight vertex-weighted matchingsGiven a bipartite graph G. For each vertex of the first part was not her weight.Required to find the maximum weight matching, iewith the largest sum of the weights of saturated peaks.Below we describe and prove the algorithm based onthe algorithm Kuhn, who will be the best solution.AlgorithmThe algorithm is extremely simple.Sort thetop of the first part, in descending order (more precisely, non-increasing) weights, and apply to the resulting graphalgorithm Kuhn.It is alleged that obtained with the maximum (in terms of number of edges) and a matching is optimal in terms of sums of weights saturated vertices (despite the fact that we actually sorting after longer use these weights).Thus, the implementation will be something like this:int n;vector g (n);vector used (n);vector order (n); // Vertex list, sorted by weight... Reading ...

for (int i = 0; i