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

Function test

code/graph/bipartite_mvc.test.cpp:2–33  ·  view source on GitHub ↗

Field testing: Kattis sensor */

Source from the content-addressed store, hash-verified

1/* Field testing: Kattis sensor */
2void test() {
3 rep(ite,0,10000) {
4 int n = rng() % 400 + 1,
5 m = rng() % 400 + 1;
6 int k = rng() % n + 1;
7 vii es;
8 rep(i,0,n) {
9 rep(j,0,m) {
10 if (rng() % k == 0) {
11 es.push_back(ii(i,j));
12 }
13 }
14 }
15 bipartite_graph g(n,m);
16 iter(it,es) {
17 g.add_edge(it->first, it->second);
18 }
19 int sz = g.maximum_matching();
20 vector<int> res = mvc_bipartite(g);
21 set<int> cover;
22 iter(it,res) cover.insert(*it);
23 assert(size(res) == sz);
24 int LEFT = 0,
25 RIGHT = n;
26 rep(i,0,size(es)) {
27 int a = LEFT + es[i].first,
28 b = RIGHT + es[i].second;
29 assert(cover.find(a) != cover.end() ||
30 cover.find(b) != cover.end());
31 }
32 }
33}
34// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 6

mvc_bipartiteFunction · 0.85
push_backMethod · 0.80
maximum_matchingMethod · 0.80
iterFunction · 0.70
insertMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected