Flow conservation (source code)

= Flow conservation

<Flow conservation> requires equal total inflow and outflow at every <vertex> other than the source and sink:
$$
\sum_{u:(u,v)\in E}f_{uv}=\sum_{w:(v,w)\in E}f_{vw}
\quad(v\notin\{s,t\}).
$$
Equivalently, the <divergence of a flow> is zero there.<Algorithms, 4th edition by Robert Sedgewick and others/FordFulkerson.java>[Algorithms, 4th edition by Robert Sedgewick and others; Sedgewick and Wayne, FordFulkerson.java, excess and isFeasible methods, lines 138–175: incoming minus outgoing amount and zero excess at nonterminal vertices]{ref}

This is a steady accounting condition: an intermediate <vertex> neither creates the routed resource nor accumulates it. Splitting is allowed; equality between individual incoming and outgoing <edges> is not required. For the running <flow>, the equation at $a$ is $f_{sa}=f_{ab}+f_{at}$, or $3=1+2$, and at $b$ it is $f_{sb}+f_{ab}=f_{bt}$, or $2+1=3$.

<Capacity constraints> alone do not ensure <flow conservation>. For instance, changing only $f_{ab}$ from $1$ to $0$ keeps every <edge> amount within its <flow network edge capacity>, but leaves an excess inflow of $1$ at $a$ and an excess outflow of $1$ at $b$. It is therefore not a <feasible flow>. Changing all affected <edge> amounts together to $(f_{sa},f_{sb},f_{ab},f_{at},f_{bt})=(2,2,0,2,2)$ restores both equations and gives <flow value> $4$.