public long flow() {
        long flow = 0;
        final SortedMap<V, Edge> edges = adjList.get(sourceNode);
        if (edges != null) {
            for (final Edge edge : edges.values()) {
                flow += edge.flow;
            }
        }
        return flow;
    }
Solve min cost flow with cycle canceling algorithm.
streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/Graph.java