MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / dfs

Method dfs

HackerEarth_problems/New Friends/solution.cpp:83–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 }
82
83 long long dfs(int v, long long pushed) {
84 if (pushed == 0)
85 return 0;
86 if (v == t)
87 return pushed;
88 for (int& cid = ptr[v]; cid < (int)adj[v].size(); cid++) {
89 int id = adj[v][cid];
90 int u = edges[id].u;
91 if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)
92 continue;
93 long long tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));
94 if (tr == 0)
95 continue;
96 edges[id].flow += tr;
97 edges[id ^ 1].flow -= tr;
98 return tr;
99 }
100 return 0;
101 }
102
103 long long flow() {
104 long long f = 0;

Callers

nothing calls this directly

Calls 2

minFunction · 0.85
dfsFunction · 0.50

Tested by

no test coverage detected