Network Flow

Created

Network Flow I

Max-Flow and Min-Cut Problems

Flow Network

A flow network is a tuple G=(V,E,s,t,c)G = (V,E,s,t,c)

  • Digraph (V,E)(V,E) with source s∈Vs \in V (assume all nodes are reachable from ss) and sink t∈Vt \in V
  • Capacity c(e)≥0c(e) \geq 0 for each e∈Ee \in E. (integer)

Intuition: material flowing through a transportation network; material originates at source and is sent to sink.

Maximum-Flow Problem

A stst-flow (flow) ff is a function that satisfies:

  • for each e∈Ee \in E, 0≤f(e)≤c(e)0 \leq f(e) \leq c(e) (capacity)
  • for each v∈V−{s,t}v \in V-\{s,t\}: ∑e in to vf(e)=∑e out of vf(e)\sum_{e \text{ in to } v} f(e) = \sum_{e \text{ out of } v} f(e) (flow conservation, meaning for every node not inclouding the source and the sink, the inflow must equal outflow)

Capacity is how much the edge can support and flow is how much is used.

The value of a flow ff is val(f)=∑e out of sf(e)−∑e in to sf(e)val(f) = \sum_{e \text{ out of } s} f(e) - \sum_{e \text{ in to } s} f(e)

  • ∑e in to sf(e)\sum_{e \text{ in to } s} f(e) is always zero because there is no flow going into the source.
  • this is the number you want to maximize.

Maximum-flow problem is to find a flow of maximum value

Minimum-Cut Problem

An stst-cut (cut) is a partition (A,B)(A,B) of the nodes with s∈As \in A and t∈Bt \in B.

Its capacity is the sum of the capacities of the edges from AA to BB. cap(A,B)=∑e out of Ac(e)cap(A,B) = \sum_{e \text{ out of } A} c(e)

Ford-Fulkerson

Greedy algorithm:

  • start with f(e)=0f(e) = 0 for each edge
  • Find an s⇝ts \rightsquigarrow t path PP where each edge has f(e)<c(e)f(e) < c(e).
  • Augment flow along path PP
  • Repeat until you get stuck

However, this algorithm may fail. Why?

  • Once greedy algorithm increases flow on an edge, it never decreases it.
  • We need some mechanism to "undo" a bad decision.

Residue Netowrk

Defining residue network

When ever you send some flow across a pipe, you create a back pipe that has the same flow in the opposite direction.

The original edge e=(u,v)∈Ee = (u,v) \in E

  • flow would be f(e)f(e)
  • capacity c(e)c(e).

The reverse edge ereverse=(v,u)e^{reverse} = (v,u)

  • "undos" the flow sent

The residue capacity:

cf(e)={c(e)−f(e),if e∈Ef(ereverse),if ereverse∈Ec_f(e) = \left\{ \begin{array}{lr} c(e) - f(e), & \text{if } e \in E\\ f(e^{reverse}), & \text{if } e^{reverse} \in E \end{array} \right.

Residual network: Gf=(V,Ef,s,t,cf)G_f=(V,E_f,s,t,c_f)

  • $E_f = {e:f(e) < c(e)} \cup {e: f(e^{reverse}) > 0}

Defining augmenting path, a simple s⇝ts \rightsquigarrow t path in the residual network GfG_f.

The bottleneck capacity of an augmenting path PP is the minimum residual capacity of any edge in PP.

Key property: let ff be the flow and let PP be an augmenting path in GfG_f. Then, after calling f′←Augment(f,c,P)f' \leftarrow Augment(f,c,P) the resulting f′f' is a flow and val(f′)=val(f)+bottleneck(Gf,P)val(f') = val(f) + bottleneck(G_f,P).

Augment(f,c,Pf,c,P)

  • δ←\delta \gets bottleneck capacity of augmenting path PP
  • For each edge e∈Pe \in P
    • If (e∈Ee \in E) f(e)←f(e)+δf(e) \gets f(e) + \delta
    • Else f(ereverse)←f(ereverse)−δf(e^{reverse}) \gets f(e^{reverse}) - \delta
  • Return ff.

Ford-Fulkerson Algorithm

Ford-fulkerson augmenting path algorithm:

  • start with f(e)=0f(e)=0 for each edge e∈Ee \in E.
  • find an s⇝ts \rightsquigarrow t path PP in the residual network GfG_f.
  • augment flow along path PP
  • repeat until you get stuck

Ford-Fulkerson(GG)

  • For each edge e∈Ee \in E : f(e)←0f(e) \gets 0
  • Gf←G_f \gets residual network of GG with respect to flow ff.
  • While (there exists an s⇝ts \rightsquigarrow t path PP in GfG_f)
    • f←f \gets Augment(f,c,Pf,c,P).
    • Update GfG_f
  • Return ff.

Max-flow min-cut theorem

Flow value lemma: Let ff be any flow and let (A,B)(A,B) be any cut, then the value of the flow ff equals the netflow across the cut (A,B)(A,B).

val(f)=∑e out of Af(e)−∑e in to Af(e)val(f) = \sum_{e \text{ out of } A} f(e) - \sum_{e \text{ in to } A} f(e)

Weak duality says that let ff be any flow and (A,B)(A,B) be any cut. Then, val(f)≤cap(A,B)val(f) \leq cap(A,B). Proof using the flow value lemma: \begin{align} val(f) &= \sum_{e \text{ out of } A} f(e) - \sum_{e \text{ in to } A} f(e) \\ &\leq \sum_{e \text{ out of } A} f(e) \\ &\leq \sum_{e \text{ out of } A} c(e) \\ &= cap(A,B) \end{align}

In other words, the value of the flow is always less than or equal to the capacity of the cut

Certificate of optimality The collorary: let ff be a flow and let (A,B)(A,B) be a min cut. If val(f)=cap(A,B)val(f) = cap(A,B) then ff is a max flow and (A,B)(A,B) is a min cut.

Proof:

  • for any flow f′f': val(f′)≤cap(A,B)=val(f)val(f') \leq cap (A,B) = val(f). (this comes from weak duality). Essentially, val(f′)≤val(f)val(f') \leq val(f).
  • for any cut (A′,B′)(A', B'): cap(A′,B′)≥val(f)=cap(A,B)cap(A', B') \geq val (f) = cap(A,B) This implies that (A,B)(A,B) is the min cut.

The max-flow min-cut theorem says that the value of the max flow = capacity of a min cut (with strong duality).

Augmenting path thoerem: a flow ff is a max flow iff no augmenting paths. Proof: the following three conditions are equivalent for any flow ff:

  1. there exists a cut (A,B)(A,B) such taht cap(A,B)=val(f)cap(A,B) = val(f)
  2. ff is a max flow
  3. there is no augmenting path with respect to ff (if ford-fulkerson terminates, then ff is max flow)

i  ⟹  iii \implies ii because this is the weak duality corollary. ii  ⟹  iiiii \implies iii because we prove the contrapositive ¬iii  ⟹  ¬ii\neg iii \implies \neg ii

  • suppose that there is an augmenting path with repsect to ff
  • can improve flow ff by sending flow along this path
  • thus, ff is not max flow. iii  ⟹  iiii \implies i
  • let ff be a flow with no augmenting paths
  • let A=A = set of nodes reachable from ss in residual network GfG_f.
  • by definition of AA: s∈As \in A
  • by definition of flow ff: t∉At \notin A.

val(f)=∑e out of Af(e)−∑e in to Af(e)=∑e out of Ac(e)−0=cap(A,B)val(f) = \sum_{e \text{ out of } A} f(e) - \sum_{e \text{ in to } A} f(e) = \sum_{e \text{ out of } A} c(e) - 0 = cap(A,B)

Baseball Eliminations

Figure out which teams have a chance of finishing the season with the most wins. We can observe that some teams are mathematically eliminated. Their maximum wins is still less than another team's minimum wins.

  • the answer depends not only on how many games they already won and left to play, but on whom they're against.