Tags:
create new tag
view all tags
int dfs(int now, int goal, int mx){ // max flow
  if(now == goal) return mx; vis[now] = 1; int temp;
  for(int i = 0; i < n + 2; i++) if(!vis[i] && flo[now][i] < cap[now][i])
    if((temp = dfs(i, goal, mx <? (cap[now][i] - flo[now][i]))))
      { flo[now][i] += temp, flo[i][now] -= temp; return temp; }
  return 0;
}
// usage: do{ memset(vis, 0, sizeof(vis)); } while(dfs(n, n + 1, 1000000));


Topic revision: r1 - 2005-11-17 - YuryKholondyrev
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback