Skip to main content

Posts

Showing posts with the label Network Flow

Basic Maxflow or Network Flow source code in c++

When there is one source and one sink and prospect is that to send maximum unit to sink then comes the need of maxflow.It is normally a bfs which helps to find the maximum capacity  over the line load and reduce this capacity from load until the load comes to zero.I mean until there is any path from source to sink. Here is the code for maxflow.Hope it help.  #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<iostream> #include<queue> #include<algorithm> using namespace std; #define INF  2147483647 /***************** Max Flow Algorithm*************** ****************************************************/ const int maxINDX=102; int flow[maxINDX][maxINDX],cap[maxINDX][maxINDX]; int path[maxINDX]; int src,dest; int BFS(int node) {     int i,item,cf;     queue<int> q;     for(i=1;i<=node;i++)       ...