Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Flow(int Source,int Destination)
- {
- int F=0,Min;
- while(BFS(Source,Destination))
- {
- for(int i=0;i<Graph[Destination].size();i++)
- if(capacity[I][Destination]-flow[I][Destination]>0||!visited[I])
- {
- Min=capacity[I][Destination]-flow[I][Destination];
- for(int j=I;j!=Source;j=father[j])
- if(capacity[father[j]][j]-flow[father[j]][j]<Min)
- Min=capacity[father[j]][j]-flow[father[j]][j];
- flow[I][Destination]+=Min;
- flow[Destination][I]-=Min;
- for(int j=I;j!=Source;j=father[j])
- flow[father[j]][j]+=Min,flow[j][father[j]]-=Min;
- F+=Min;
- }
- }
- return F;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement