Open
Description
int maxFlow(int[][] cap, int source, int sink) {
for (int flow = 0; ; ++flow)
if (!augmentPath(cap, new boolean[cap.length], source, sink))
return flow;
}
boolean augmentPath(int[][] cap, boolean[] vis, int i, int sink) {
if (i == sink) return true;
vis[i] = true;
for (int j = 0; j < vis.length; j++)
if (!vis[j] && cap[i][j] > 0 && augmentPath(cap, vis, j, sink)) {
--cap[i][j];
++cap[j][i];
return true;
}
return false;
}
Metadata
Metadata
Assignees
Labels
No labels