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

Method max_flow

code/graph/dinic.cpp:22–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 return (e[i].cap -= ret, e[i^1].cap += ret, ret);
21 return 0; }
22 int max_flow(int s, int t, bool res=true) {
23 e_store = e;
24 int l, r, f = 0, x;
25 while (true) {
26 memset(d, -1, n*sizeof(int));
27 l = r = 0, d[q[r++] = t] = 0;
28 while (l < r)
29 for (int v = q[l++], i = head[v]; i != -1; i=e[i].nxt)
30 if (e[i^1].cap > 0 && d[e[i].v] == -1)
31 d[q[r++] = e[i].v] = d[v]+1;
32 if (d[s] == -1) break;
33 memcpy(curh, head, n * sizeof(int));
34 while ((x = augment(s, t, INF)) != 0) f += x; }
35 if (res) reset();
36 return f; } };
37// vim: cc=60 ts=2 sts=2 sw=2:

Callers 12

construct_gh_treeFunction · 0.45
testFunction · 0.45
test1Function · 0.45
test2Function · 0.45
test3Function · 0.45
testFunction · 0.45
test1Function · 0.45
test2Function · 0.45
test3Function · 0.45
testFunction · 0.45
test_randFunction · 0.45
test_1Function · 0.45

Calls 1

augmentFunction · 0.85

Tested by 11

testFunction · 0.36
test1Function · 0.36
test2Function · 0.36
test3Function · 0.36
testFunction · 0.36
test1Function · 0.36
test2Function · 0.36
test3Function · 0.36
testFunction · 0.36
test_randFunction · 0.36
test_1Function · 0.36