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

Function test_rand

code/graph/bipartite_matching.test.cpp:3–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "../code/graph/dinic.cpp"
2
3void test_rand(int N, int M) {
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 flow_network g(N + M + 2);
13
14 int SOURCE = N + M;
15 int SINK = N + M + 1;
16
17 for(int i = 0; i < N; i++) {
18 g.add_edge(SOURCE, i, 1, 0);
19 for(int j = 0; j < M; j++) {
20 if(rng() % 2) {
21 // cout << i << " -> " << j << endl;
22 g.add_edge(i, N + j, 1, 0);
23 adj[i].push_back(j);
24 }
25 }
26 }
27
28 for(int j = 0; j < M; j++) {
29 g.add_edge(j + N, SINK, 1, 0);
30 }
31
32 int sum = 0;
33 for(int i = 0; i < N; ++i) {
34 memset(done, 0, sizeof(bool) * N);
35 sum += alternating_path(i);
36 }
37
38 assert_equal(g.max_flow(SOURCE, SINK), sum);
39
40 delete[] adj;
41 delete[] done;
42 delete[] owner;
43}
44
45void test_1() {
46 int N = 3, M = 3;

Callers 1

testFunction · 0.70

Calls 5

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

Tested by

no test coverage detected