The maximum flow problem asks: given a directed network with capacities on each edge, how much “stuff” (water, traffic, data, money, etc.) can be sent from a source node s to a sink node t without exceeding any edge capacity? This calculator solves that problem for a fixed-size network of 5 nodes labeled 0–4, using the Edmonds–Karp algorithm (a specific, polynomial-time variant of the Ford–Fulkerson method).
You provide a 5×5 capacity matrix c(i,j), where each entry represents the capacity of the directed edge from node i to node j. A capacity of 0 means “no usable edge” (or an edge with zero capacity). The calculator then finds the maximum feasible flow value from the chosen source to the chosen sink.
Each input labeled cij corresponds to capacity from node i to node j. For example:
c01 is the capacity on edge 0 → 1c34 is the capacity on edge 3 → 4Directed vs. undirected: this is a directed-network calculator. To model an undirected edge between i and j with capacity C, enter cij = C and cji = C.
Choose:
If s = t, the maximum flow value is typically 0 (there is no need to send flow across edges to reach the sink).
A flow assigns a value f(u,v) to each directed edge (u,v). It must satisfy:
The value of the flow is the total amount leaving the source (equivalently, the total amount entering the sink in a feasible flow).
The standard definitions can be written as:
In this calculator, V has exactly 5 nodes (0–4), and the capacities c(u,v) are your inputs.
Ford–Fulkerson increases flow by repeatedly finding an augmenting path from s to t in the residual network—a graph that tracks how much additional flow can be pushed on each edge (and how much can be “undone” via reverse edges). The Edmonds–Karp variant always chooses an augmenting path found by BFS (fewest edges), which guarantees polynomial runtime.
Key idea: the amount you can add along a path is limited by its bottleneck (the minimum residual capacity on the path). After pushing that amount, residual capacities update: forward edges decrease; reverse edges increase.
The main output is the maximum flow value: the greatest feasible amount that can be sent from your chosen source to sink. Useful ways to interpret it:
Use source s = 0 and sink t = 4. Enter these nonzero capacities (all unspecified entries are 0):
c01 = 10, c02 = 5c13 = 15, c14 = 10c23 = 10, c24 = 10c34 = 10One feasible sequence of augmentations (your algorithm may find the same value via different intermediate paths):
The computed maximum flow for this network is 20.
Takeaway: even though there may be many paths from 0 to 4, the combined capacities leaving node 0 (10+5=15) and other downstream constraints determine the true maximum. In this example, additional routing through node 3 helps achieve the final total.
| Algorithm | Main idea | Typical complexity (conceptual) | When it’s a good fit |
|---|---|---|---|
| Ford–Fulkerson | Repeatedly augment along any s–t path in residual graph | Depends on path choice; can be slow with irrational capacities | Small graphs; educational use |
| Edmonds–Karp | Ford–Fulkerson + BFS for shortest augmenting paths | Polynomial; O(V·E²) | Reliable, simple, great for small/medium graphs |
| Dinic | Blocking flows in level graphs | Often faster in practice; strong bounds on many cases | Larger graphs where performance matters |
| Push–relabel | Local pushes with node “heights” and excess flow | Very fast on many dense graphs | Industrial-scale max-flow / dense networks |
cij applies to i → j only. Use both directions to mimic an undirected link.c00, c11, etc. represent self-loops. In most flow models, self-loops are ignored and do not help increase s–t flow; you can leave them as 0.