int main()
{
int i,j,k,l,m;
int maxflow=0;
int first,second,capac;
int residual[100][100];
//reading from file
FILE*fp;
fp=fopen("ford.txt","r");
fscanf(fp,"%d %d",&node,&edge);
cout<<"nodes are"<<node<<"\n"<<"edges are"<<edge<<"\n";
for(j=1;j<=node;j++)
{
for(k=1;k<=node;k++)
{
capacity[j][k]=0;
}
}
for(i=0;i<edge;i++)
{
fscanf(fp,"%d %d %d",&first,&second,&capac);
cout<<first<<"->"<<second<<"="<<capac<<"\n"; //it is printing this
capacity[first][second]=capac;//crashes here at last i/p i.e.1=edge-1
}
cout<<"abc"; //this is not printed
for(l=1;l<=node;l++)
{
for(m=1;m<=node;m++)
{
flow[l][m]=capacity[l][m];
flow[m][l]=0;
}
}
return 0;
}
It is not even printing the "abc" in the cout statement. I am trying to implement the Ford-Fulkerson algorithm. Here I am reading from a file and initializing capacity flow matrices. After that I am calling maxflow function, which I have omitted here.