| 1 | |
| 2 | void test() { |
| 3 | int N = 20; |
| 4 | int MAX = 10000; |
| 5 | |
| 6 | flow_network g(N); |
| 7 | pair<vii, vvi> gh; |
| 8 | |
| 9 | for(int i = 0; i < N; i++) { |
| 10 | for(int j = i+1; j < N; j++) { |
| 11 | gh = construct_gh_tree(g); |
| 12 | for(int x = 0; x < N; ++x) { |
| 13 | for(int y = 0; y < N; ++y) { |
| 14 | if (x == y) continue; |
| 15 | assert_equal(g.max_flow(x, y), compute_max_flow(x, y, gh)); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | int cap = rng() % MAX; |
| 20 | g.add_edge(i, j, cap, cap); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | gh = construct_gh_tree(g); |
| 25 | for(int i = 0; i < N; ++i) { |
| 26 | for(int j = 0; j < N; ++j) { |
| 27 | if (i == j) continue; |
| 28 | assert_equal(g.max_flow(i, j), compute_max_flow(i, j, gh)); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | |
| 33 | // TODO: fix GH, and then uncomment these tests (they fail with low probability) |
| 34 | // N = 500; |
| 35 | // g = flow_network(N); |
| 36 | // int cnt = 0; |
| 37 | // rep(i,0,N) { |
| 38 | // rep(j,0,N) { |
| 39 | // if (rng() % 1000 == 0) { |
| 40 | // g.add_edge(i,j,rng() % MAX); |
| 41 | // cnt++; |
| 42 | // } |
| 43 | // } |
| 44 | // } |
| 45 | // |
| 46 | // gh = construct_gh_tree(g); |
| 47 | // rep(i,0,N) { |
| 48 | // int a = rng() % N, |
| 49 | // b = rng() % N; |
| 50 | // assert_equal(g.max_flow(a,b), compute_max_flow(a,b,gh)); |
| 51 | // } |
| 52 | } |
| 53 | |
| 54 | // vim: cc=60 ts=2 sts=2 sw=2: |
nothing calls this directly
no test coverage detected