I tried implementing the relax in edge in Ford Fulkerson. I tried to substitute it for has augmenting path, but I couldn't get the parameters quite right. So then I tried putting it into the has augmenting path which is what I put below. Logically, it makes sense to me, but I keep getting an Illegal Increase exception and I don't know why. Could you point me in the right direction? I thought maybe it was saying that because I was trying to relax an edge and increase the index when I wasn't supposed to, but I am still confused.

Thanks for any advice.

// is there an augmenting path? // if so, upon termination edgeTo[] will contain a parent-link representation of such a path private boolean hasAugmentingPath(FlowNetwork G, int s, int t) { edgeTo = new FlowEdge[G.V()]; marked = new boolean[G.V()]; // breadth-first search IndexMaxPQ<Double> q = new IndexMaxPQ<Double>(G.V()); q.insert(s, Double.POSITIVE_INFINITY); marked[s] = true; while (!q.isEmpty()) { int v = q.delMax(); for (FlowEdge e : G.adj(v)) { int w = e.other(v); // if residual capacity from v to w if (e.residualCapacityTo(w) > 0) { /** q.insert(w, e.flow()); edgeTo[w] = e; System.out.println(e); **/ marked[w] = true; double flowKeep = e.flow();// = 0.0; //keeps track of the current flow on an edge if (flowKeep < e.capacity()) { // the flow on the FlowEdge is greater than the flow on that before it flowKeep = e.capacity();//set flowKeep to that new edge edgeTo[w] = e;//make edge to w the new "last edge" looked at if (q.contains(w)) q.decreaseKey(w, flowKeep); else q.insert(w, flowKeep); } } } } // is there an augmenting path? return marked[t]; }