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

Function test_1

code/graph/bipartite_matching.test.cpp:45–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void test_1() {
46 int N = 3, M = 3;
47
48 adj = new vi[N];
49
50 done = new bool[N];
51
52 owner = new int[M];
53 memset(owner, -1, sizeof(int) * M);
54
55 flow_network g(N + M + 2);
56
57 int SOURCE = N + M;
58 int SINK = N + M + 1;
59
60 for(int i = 0; i < N; i++) {
61 g.add_edge(SOURCE, i, 1, 0);
62 }
63
64 int graph[][2] = { { 0, 0 }, { 0, 1 }, { 1, 2 }, { 2, 0 }, { 2, 2 } };
65
66 for(int i = 0; i < 4; ++i) {
67 g.add_edge(graph[i][0], graph[i][1] + N, 1, 0);
68 adj[graph[i][0]].push_back(graph[i][1]);
69 }
70
71 for(int j = 0; j < M; j++) {
72 g.add_edge(j + N, SINK, 1, 0);
73 }
74
75 int sum = 0;
76 for(int i = 0; i < N; ++i) {
77 memset(done, 0, sizeof(bool) * N);
78 sum += alternating_path(i);
79 }
80
81 assert_equal(g.max_flow(SOURCE, SINK), sum);
82
83 delete[] adj;
84 delete[] done;
85 delete[] owner;
86}
87
88void test() {
89 test_1();

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