I'm trying to implement the Ford Fulkerson algorithm in Java. So far I have a graph with Nodes and Edges. The nodes contains an ID string and an adjacencyList of edges. The edges contain the capacity and the node it leads to.

I'm trying to understand the psudo code on the Wikipedia page and how to implement it (I'm using Java). This is what I understand so far:

1. First I set the flow of all edges in the graph to zero.(What is a good way to represent flow? Directly in the edges of my graph as a variable?)
2. The second step is to create the residual graph which is a network where the edges have the residual capacity: capacity - flow (of the corresponding edges in the "normal graph"). Then you find a path from the source to the sink using this residual graph and find the minimal capacity along this path. (This is where stuff gets really tricky, should I create an entirely new graph for the residual graph or should I represent it somehow in the original graph? What is the best way?)

Step 2 is repeated until no path can be found but every time it is found you do step 3 and 4:

1. For each edge along the path you add the minimal value found in step 2.
2. For each edge in the opposite direction of the path you subtract the minimal value found in step 2.

Step 3 and 4 puzzles me since I feel like it is the same thing to add in one direction as it is to substracting in the opposite. These additions and substractions are made in the graph right, not the residual graph?

Would really appreciate some help, I have been trying to wrap my head around this for a couple of hours now but I just can't seem to understand it.