Hi,
I'm working on a C++ mini-project ( I'm having an unoriented graph for wich I have an admissible flow and I have to determine the minimal flow for it). Everithing works fine, it compiles and runs well (the code is below) but I'm using files to read input and to show results. I wish I realised a graphical interface for it but I don't know how...Could someone give me some ideas, recommend me a good tutorial?
Thank you!

#include<iostream>  
      #include<fstream>
      using namespace std;
	  int c[100][100], f[100][100], l[100][100], r[100][100], n, m, head, tail, q[100], color[100], pred[100];

	#define WHITE 0
	#define GRAY 1
	#define BLACK 2

	  int read_input_file()
	  {
		 int i, j, k;
		  int iarc, farc, capacity, flow, low;
		  ifstream ipoteze;
		  ipoteze.open("C:\\Documents and Settings\\S&D\\Desktop\\dateDeIntrare.txt");
		  ipoteze>>n>>m; 

		   for (i=0; i<n; i++) 
			for (j=0; j<n; j++) {
				c[i][j] = 0;
				f[i][j] = 0;
				l[i][j] = 0;
			}
		   

		   for(k=0; k<m; k++)
		   {
			   ipoteze>>iarc>>farc>>low>>flow>>capacity;
			   c[iarc][farc] = capacity;
			   f[iarc][farc] = flow;
			   l[iarc][farc] = low;
 		   }

		  
		  for(i=0; i<n; i++)
			  for(j=0; j<n; j++)
			  {
				  r[i][j] = c[j][i]-f[j][i]+f[i][j]-l[i][j];
			  }


		  ipoteze.close();

		  return 0;
	  }
	  int print_results()
	  {
		int i, j, u; 
		ofstream rezultate;
		rezultate.open("C:\\Documents and Settings\\S&D\\Desktop\\dateDeIesire.txt"); 
		for(i=0; i<n; i++)
		{
			for(j=0; j<n; j++)
			rezultate<<c[i][j]<<" ";
			rezultate<<"\n";
		}
		rezultate<<"\n";
		for(i=0; i<n; i++)
		{
			for(j=0; j<n; j++)
			rezultate<<f[i][j]<<" ";
			rezultate<<"\n";
		}
		rezultate<<"\n";
		for(i=0; i<n; i++)
		{
			for(j=0; j<n; j++)
			rezultate<<l[i][j]<<" ";
			rezultate<<"\n";
		}
		rezultate<<"\n";
		for(i=0; i<n; i++)
		{
			for(j=0; j<n; j++)
			rezultate<<r[i][j]<<" ";
			rezultate<<"\n";
		}
		rezultate<<"\n";
//		for (u=n-1; pred[u]>=0; u=pred[u])
//			rezultate<<u<<" ";

		rezultate.close();
		return 0;

	  }
int adaug_in_coada (int x) {
    q[tail] = x;
    tail++;
    color[x] = GRAY;
	return 0;
}

int scot_din_coada () {
   int x = q[head];
    head++;
    color[x] = BLACK;
    return x;
}


	  int bfs (int start, int target) {
    int u,v;
    for (u=0; u<n; u++) {
	color[u] = WHITE;
    }   
    head = tail = 0;
    adaug_in_coada(start);
    pred[start] = -1;
    while (head!=tail) {
	u = scot_din_coada();
        // Search all adjacent white nodes v. If the capacity
        // from u to v in the residual network is positive,
        // enqueue v.
	for (v=0; v<n; v++) {
	    if (color[v]==WHITE && (f[u][v]-l[u][v]>0 || c[v][u]-f[v][u]>0)) {
		adaug_in_coada(v);
		pred[v] = u;
	    }
	}
    }
    // If the color of the target node is black now,
    // it means that we reached it.
    return color[target]==BLACK;
}

	  int algoritm_generic(int nod_sursa, int nod_tinta)
	  {
		int increment, u,i ,j;
		  while(bfs(nod_sursa,nod_tinta))
		  {
				increment = 1000000;
				for (u=n-1; pred[u]>=0; u=pred[u]) 
					if(f[pred[u]][u]-l[pred[u]][u]>0)
						increment = min(increment,r[pred[u]][u]);
					else
						increment = min(increment, r[u][pred[u]]);

				for (u=n-1; pred[u]>=0; u=pred[u]) 
					if(f[pred[u]][u]-l[pred[u]][u]>0)
						f[pred[u]][u] = f[pred[u]][u] - increment;
					else
						f[u][pred[u]] = f[u][pred[u]] + increment;
				for(i=0; i<n; i++)
					for(j=0; j<n; j++)
					{
						r[i][j] = c[j][i]-f[j][i]+f[i][j]-l[i][j];
					}

		  }

		  return 0;
	  }




      int main()
      {
		  
	  read_input_file();
	  algoritm_generic(0, 3);
//	  bfs(0,3);
  	  print_results();
      return 0;
  }
This article has been dead for over six months. Start a new discussion instead.