Question: Plese fix the code. I don't know why it don't work, it does not give me ouput, like below. here is the what the output

Plese fix the code. I don't know why it don't work, it does not give me ouput, like below.

here is the what the output of the program should be:

Plese fix the code. I don't know why it don't work, it

here what I got so far. It don't wok. Thank you.

#include  #include  #include  #include  #include  using namespace std; #define V 1000 bool findAugmentingPath(int n, int s, int t, int *rGraph, int path[]) { bool visited[V]; memset(visited, 0, sizeof(visited)); queue int> q; q.push(s); visited[s] = true; path[s] = -1; // Standard BFS Loop while (!q.empty()) { int u = q.front(); q.pop(); for (int v=0; vif (visited[v]==false && *(rGraph + u*n + v) > 0) { q.push(v); path[v] = u; visited[v] = true; } } } return (visited[t] == true); } // do not change the parameters in this function. void maximum_flow(int n, int s, int t, int *capacity, int *flow)//this is the function prototype that professor gave. { int i, j, res_cap[n][n], path[n]; // to hold residual capacity and BFS' augmenting path int min_flow_path = INT_MAX; // to hold the min of the augmenting path // Assign residual capacity equal to the given capacity for (i = 0; i for (j = 0; j while (findAugmentingPath(n, s, t, &(res_cap[0][0]), path)) { // find min of the augmenting path for (j = t; j != s; j = path[j]) { i = path[j]; min_flow_path = min(min_flow_path, res_cap[i][j]); } // update residual capacities and flows on both directions for (j = t; j != s; j = path[j]) { i = path[j]; if(*(capacity + i*n + j) > 0) *(flow + i*n + j) += min_flow_path; else  *(flow + j*n + i) -= min_flow_path; res_cap[i][j] -= min_flow_path; res_cap[j][i] += min_flow_path; } } } // do not modify main. Also professor gave to test the program. int main(void) { int cap[1000][1000], flow[1000][1000]; int i,j, flowsum; for(i=0; ifor( j =0; jfor(i=0; ifor( j=i+1; jfor(i=1; ifor(i=500; i for( i=754; ifor(i=0; ifor(j=0; jif( flow[i][j] > cap[i][j] ) { cout for(i=0; ifor(i=0; i  Outflow of 0 is 10, should be 10 Inflow of 999 is 10, should be 10 End Test

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!