public Graph<V> residualGraph() {
        if (isResidualGraph) {
            return this;
        }

        final Graph<V> residualGraph = new Graph<>(true);
        for (final Map.Entry<V, SortedMap<V, Edge>> nodeEdges : adjList.entrySet()) {
            final V node = nodeEdges.getKey();
            final SortedMap<V, Edge> edges = nodeEdges.getValue();
            for (final Entry<V, Edge> nodeEdge : edges.entrySet()) {
                final Edge edge = nodeEdge.getValue();
                final Edge forwardEdge = new Edge(edge.destination, edge.capacity, edge.cost, edge.capacity - edge.flow, edge.flow);
                final Edge backwardEdge = new Edge(node, edge.capacity, edge.cost * -1, edge.flow, 0, false);
                forwardEdge.counterEdge = backwardEdge;
                backwardEdge.counterEdge = forwardEdge;
                residualGraph.addEdge(node, forwardEdge);
                residualGraph.addEdge(edge.destination, backwardEdge);
            }
        }
        residualGraph.setSourceNode(sourceNode);
        residualGraph.setSinkNode(sinkNode);
        return residualGraph;
    }
Get residual graph of this graph.
Residual graph definition:
If there is an edge in original graph from u to v with capacity c, cost w and flow f,
then in the new graph there are two edges e1 and e2. e1 is from u to v with capacity c - f,
cost w and flow f. e2 is from v to u with capacity f, cost -w and flow 0.

@return Residual graph
streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java