MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / max_matching

Function max_matching

code/graph/blossom.cpp:73–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71 emarked[v][w] = emarked[w][v] = true; }
72 marked[v] = true; } return q; }
73vii max_matching(const vector<vi> &adj) {
74 vi m(size(adj), -1), ap; vii res, es;
75 rep(i,0,size(adj)) iter(it,adj[i]) es.emplace_back(i,*it);
76 shuffle(es.begin(), es.end(), rng);
77 iter(it,es) if (m[it->first] == -1 && m[it->second] == -1)
78 m[it->first] = it->second, m[it->second] = it->first;
79 do { ap = find_augmenting_path(adj, m);
80 rep(i,0,size(ap)) m[m[ap[i^1]] = ap[i]] = ap[i^1];
81 } while (!ap.empty());
82 rep(i,0,size(m)) if (i < m[i]) res.emplace_back(i, m[i]);
83 return res; }
84// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 3

find_augmenting_pathFunction · 0.85
iterFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected