Context:FIT2004_MOC Β· the W12 lecture + applied sheet β max flow recast as a feasibility test: no s/t, a demand on every vertex, a [β,c] window on every edge Β· solved by one Ford-Fulkerson run, the next step after Network Flow ReductionsParent Framework:Ford-Fulkerson Method
Quick Revision
π― Objective: demands β super s/t edges β FF β feasible βΊ every super-edge saturated Β· lower bounds β pre-push β, adjust d and c, solve the remainder, add β back.
β‘ Key Constraint: two signs decide everything β dvβ<0 is a supplier (edge froms), dvβ>0 a consumer (edge tot) Β· dvββ=dvβββinβ(v)+βoutβ(v), never the reverse.
π How It Works
1. Circulation with Demands
Capacity constraint β 0β€f(e)β€c(e), unchanged from max flow.
Demand constraint replaces conservation β in(v)βout(v)=dvβ at every vertex Β· no source, no sink.
Why no s/t β a source is just a vertex with negative demand and a sink one with positive demand β the demands take over both roles, and β0 demand is still demandβ.
Reading dvβ β dvβ>0 βΉ vabsorbsdvβ (in 5, out 3, d=2) Β· dvβ<0 βΉ vsuppliesβdvβ (in 3, out 5, d=β2) Β· dvβ=0 βΉ plain conservation, ignored by the construction.
Feasibility, not optimisation β βdoes anyf satisfy both constraints?β β answer yes/no, with the flow as the witness.
2. Deciding Feasibility With One Max Flow (lecture)
Construction β new s with sβv of capacity βdvβ for every dvβ<0 Β· new t with vβt of capacity dvβ for every dvβ>0 Β· original edges kept βΉ network Gβ².
Run FF β s to t on Gβ², unmodified.
Test β feasible βΊ every s-edge and every t-edge is saturated βΊβ£fβ£=D+=Dβ, where D+=βdvβ>0βdvβ, Dβ=βdvβ<0β(βdvβ) Β· D+ξ =Dβ βΉ infeasible without running FF Β· D+=Dβ (i.e. βdvβ=0) is necessary, not sufficient β the Clayton network passes it and is still infeasible (Β§Applied).
Read-off β delete s, t and their edges; the flow left on the original edges is the circulation (βclean it upβ).
Why (βΈ) β a saturated sβv hands v exactly βdvβ of extra inflow; conservation in Gβ² then forces inGβ(v)βoutGβ(v)=dvβ β symmetric for vβt.
Why (βΉ) β a feasible circulation plus full super-edges conserves at every v and has value D+=c({s},β ) βΉ maximum by weak duality (Min-Cut Max-Flow Theorem Β§3), so FF reaches it too.
Integer witness β integer c, d βΉ FF returns an integer circulation (Ford-Fulkerson Method Β§5) β the lectureβs βwe only deal with integersβ, and what makes a 0/1 edge read-off legal.
3. Lower Bounds β Pre-Push, Then Solve the Remainder (lecture Β· applied P1)
New constraint β β(e)β€f(e)β€c(e) Β· demand constraint unchanged.
Step 1 β pre-push β fββ(e)=β(e) on every edge; this alone usually breaks the demands.
Step 2 β reduced network Gβ β same vertices and edges, no lower bounds:
Step 3 β circulation with demands {dvββ} on Gβ by Β§2 βΉ fβ, or infeasible.
Step 4 β combine β f=fββ+fβ βΉ ββ€fβ€c because 0β€fββ€cββ Β· annotate edges β/f/c and restore the originaldvβ (βdonβt forget the demandβ).
Equivalence β f feasible in GβΊfβfββ feasible in Gβ βΉ Gβ infeasible means G infeasible; nothing is lost.
4. Modelling With Circulations (lecture Β· applied P4, P6)
Recipe β fixed supplies = negative demands, fixed needs = positive demands, βat least a, at most bβ = edge window [a,b] β Β§3 then Β§2 β read the assignment off edges carrying 1.
Survey design (lecture) β qβciβ window [ciββ,ci+β] (reviews asked of customer i) Β· ciββpjβ window [0,1] if i used pjβ (one review per product) Β· pjββf window [pjββ,pj+β] Β· closing edge fβq window [βciββ,βci+β] Β· all demands 0 β bipartite matching with lower bounds; reviews = middle edges carrying 1.
Airline scheduling, k planes (lecture) β route riβ= edge depiββarriβ window [1,1] (vital βΉ must fly) Β· s (d=βk) βdepiβ[0,1] (start anywhere) Β· arriββt (d=k) [0,1] (retire anywhere) Β· arriββdepjβ[0,1] when a plane can fly rjβ after riβ Β· sβt[0,k] for idle planes β feasible βΊk planes cover every route Β· each unit sβt is one planeβs itinerary.
Weekend roster (applied P4a) β a (d=βD, D= number of weekend days) βeiβ window [βiβ,miβ] Β· eiββwjβ[0,1] if available Β· dwjββ=1, deiββ=0 β roster = edges eiββwjβ carrying 1.
Why the extra vertex a β each day needs exactly one person (a demand) but each employee only a range (an edge window); only the total D is fixed, so it sits on a.
At most one day per weekend (P4b) β a selectorsi,kβ per employee per weekend: eiββsi,kβ[0,1], si,kββwjβ[0,1] for each available day of weekend k Β· a capacity on a group of edges β the vertex-split idea of Network Flow Reductions Β§2.
Baseball elimination (applied P6) β team x wins every remaining game βΉ y wins Β· drop xβs games Β· one node Gi,jβ per pair (d=βrijβ, games left between i and j) βTiβ and βTjβ, capacity rijβ Β· TiββA capacity yβwiβ Β· dAβ=βrijβ β feasible βΊx can still finish at least tied Β· any yβwiβ<0 βΉ x is out before building (the sheetβs βtrivialβ case).
βοΈ Core Implementation
πΉ Feasible circulation with demands and lower bounds (applied P7)
def circulation(n, edges, d): """edges = [(u, v, lo, hi)]; d[v] = in - out. Returns per-edge flows, or None.""" d = d[:] # becomes d*; never mutate the input adj = [[] for _ in range(n + 2)] s, t = n, n + 1 handles = [] for u, v, lo, hi in edges: # 1. pre-push lo O(E) d[v] -= lo # lo already arrived at v d[u] += lo # u must refill what it shipped handles.append((u, len(adj[u]), lo, hi)) # index of the forward edge add_edge(adj, u, v, hi - lo) # c* = c - l pos = neg = 0 for v in range(n): # 2. super source/sink O(V) if d[v] < 0: add_edge(adj, s, v, -d[v]); neg -= d[v] elif d[v] > 0: add_edge(adj, v, t, d[v]); pos += d[v] if pos != neg or ford_fulkerson(adj, s, t) != pos: return None # 3. some super-edge unsaturated return [lo + (hi - lo - adj[u][i].cap) # 4. f = l + f*, f* = c* - residual for u, i, lo, hi in handles]
π‘ Common Mistake:Testing only ford_fulkerson(...) == pos β with Dβ>D+ the t-edges can all fill while an s-edge stays short; check both sides.
βοΈ Complexity
(The lecture states no bound β each row applies Ford-Fulkerson Methodβs O(FE) to the built network.)
Step
Time
Aux space
Why
Lower-bound transform
O(V+E)
Ξ(V)
one pass for cβ and both β-sums
Add s, t
O(V)
Ξ(V)
β€V super-edges βΉ Eβ²β€E+V
FF on Gβ²
O(D+(V+E))
Ξ(V+E)
Fβ€c({s},β )=Dβ, and =D+ when feasible β pseudo-polynomial in the demands
Combine f=fββ+fβ
O(E)
β
one addition per edge
Whole pipeline
O(Dβ(V+E))
Ξ(V+E)
Dβ=βdvββ>0βdvββ
βοΈ Core Decision Matrix
Problem
Cue in the question
Construction
Answer
Max flow
one origin, one destination, βhow muchβ
network as given
β£fβ£
Circulation with demands
fixed supplies and needs, no single s/t
sβ suppliers, consumers βt
feasible βΊ super-edges saturated
+ lower bounds
βat leastβ on a link (must fly, minimum workload)
pre-push β β Gβ β demands
f=fββ+fβ
When It Flips: "at least" on an edge βΉ lower bounds Β· "exactly / supplies / needs" on a vertex βΉ demands Β· only "at most" and one origin βΉ plain max flow or quota matching (Network Flow Reductions Β§3).
Final Extracted Output:infeasible β w must net-absorb 4 but at most 3 can reach it, so wβt never saturates Β· certificate: the cut (Vβ²β{w,t},{w,t}) of capacity 4<D+=5.
β οΈ Common Mistakes
π‘ Demand sign flipped β dvβ<0 is a supplier: edge sβv, never vβt.
π‘ dβ sign flipped β incoming lower bounds are subtracted, outgoing added Β· self-check: βdvββ=βdvβ, since each β is subtracted once at its head and added once at its tail.
π‘ Reporting fβ as the circulation β the answer is f=fββ+fβ under the original demands; fβ alone breaks every lower bound.
π‘ βdvβ=0 read as feasible β it only clears the quick reject; the saturation test decides.
π‘ βFF finishedβ read as βfeasibleβ β FF always returns a max flow; feasibility is the extra saturation test.
π§ Active Recall
Why is "every super-edge saturated" exactly the feasibility test, in both directions?
Answer
Short answer: saturated super-edges are the demands; a feasible circulation plus full super-edges is a flow of value D+, which no flow can beat.
Why:(βΈ) β deleting a saturated sβv of capacity βdvβ leaves v with inβout=dvβ; same for t-edges. (βΉ) β the cut ({s},Vβ²β{s}) has capacity Dβ=D+, so a flow of that value is maximum by weak duality βΉ FF reaches it.
Airline scheduling: why is a route an edge with window [1,1], and why the edge sβt?
Hint: what can a lower bound say that a capacity cannot?
Answer
Short answer: βthis route must be flownβ is a lower bound, and lower bounds live on edges; sβt soaks up planes nobody needs.
Why:β=c=1 β exactly one plane crosses depiββarriβ Β· [0,1] elsewhere β starting, retiring and chaining stay optional Β· sβt[0,k] β without it dsβ=βk forces all k planes to fly, making βk is enoughβ fail whenever fewer suffice.
Weekend roster (P4): why do days carry demand 1 while employees need an extra vertex a?
Answer
Short answer: a demand is an exact number; employees have a range, and ranges are edge windows.
Why:Days β exactly one person each βΉ dwjββ=1 Β· Employees β βiββ€ shifts β€miβ βΉ window on aβeiβ Β· Totals β only βjβ1=D is fixed, so the balancing supply βD sits on a.
Baseball elimination: why does capacity yβwiβ on TiββA encode "nobody passes team x"?
Answer
Short answer: it caps how many of the remaining games team i may still win while staying β€y.
Why:Every game must be awarded β dGi,jββ=βrijβ forces all rijβ wins out to Tiβ or Tjβ Β· No team exceeds y β wiβ+(flowΒ intoΒ Tiβ)β€y Β· Infeasible β some wins have nowhere legal to go βΉ someone must pass x βΉ x eliminated.