private static int computeMaxFlow(){
  int sum;
  for (int i=1; i < n - 1; i++) {
    sum=0;
    for (int j=0; j < n; j++) {
      sum=sum + outgoing[j][i] - outgoing[i][j];
    }
    if (sum != 0) {
      return -1;
    }
  }
  sum=0;
  for (int j=0; j < n; j++) {
    sum=sum + outgoing[0][j];
  }
  return sum;
}

private static int computeMaxFlow ( ) { int sum ; for ( int i = 1 ; i < n - 1 ; i ++ ) { sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) { sum = sum + outgoing [ j ] [ i ] - outgoing [ i ] [ j ] ; } if ( sum != 0 ) { return - 1 ; } } sum = 0 ; for ( int j = 0 ; j < n ; j ++ ) { sum = sum + outgoing [ 0 ] [ j ] ; } return sum ; }
return - 1 if some flow constraint not met ; otherwise return the max flow .
