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

Function test_rand

code/graph/hopcroft_karp.test.cpp:3–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "../code/graph/bipartite_matching.cpp"
2
3void test_rand(int N, int M, int sparseness = 2) {
4 adj = new vi[N];
5
6 done = new bool[N];
7 memset(done, 0, sizeof(bool) * N);
8
9 owner = new int[M];
10 memset(owner, -1, sizeof(int) * M);
11
12 bipartite_graph g(N, M);
13
14 for(int i = 0; i < N; i++) {
15 for(int j = 0; j < M; j++) {
16 if(rng() % sparseness == 0) {
17 g.add_edge(i, j);
18 adj[i].push_back(j);
19 }
20 }
21 }
22
23 int sum = 0;
24 for(int i = 0; i < N; ++i) {
25 memset(done, 0, sizeof(bool) * N);
26 sum += alternating_path(i);
27 }
28
29 assert_equal(sum, g.maximum_matching());
30
31 delete[] adj;
32 delete[] done;
33 delete[] owner;
34}
35
36void test() {
37 int TESTS = 1000, MAX_N = 400, MAX_M = 300;

Callers 1

testFunction · 0.70

Calls 5

alternating_pathFunction · 0.85
push_backMethod · 0.80
maximum_matchingMethod · 0.80
assert_equalFunction · 0.50
add_edgeMethod · 0.45

Tested by

no test coverage detected