Quiz 2
Registry Synced

Applications of Network Flow

925 words
5 min read

Reading compass

Now · 🎯 Learning Objectives

Applications of Network Flow

🎯 Learning Objectives

  • Model real-world problems as flow networks
  • Apply max-flow min-cut to bipartite matching
  • Solve scheduling with flow networks
  • Analyze baseball elimination using min-cut
  • Formulate project selection as flow

1. Bipartite Matching

1.1 Problem

Given bipartite graph G=(UV,E)G = (U \cup V, E), find maximum matching (largest set of edges with no shared vertices).

1.2 Flow Formulation

Add source ss connected to all uUu \in U (capacity 1), all vVv \in V connected to sink tt (capacity 1). Set all edges uvu \to v with capacity 1. Max flow = max matching size. (Diagram)

1.3 Tracing

IterationAugmenting PathFlow AddedMatching
1s→u1→v1→t1(u1,v1)
2s→u2→v2→t1(u1,v1), (u2,v2)
3s→u3→v3→t1(u1,v1), (u2,v2), (u3,v3)
Max matching = 3 (perfect matching).

2. Scheduling with Release Times and Deadlines

2.1 Problem

nn jobs, each with processing time pip_i, release time rir_i, deadline did_i. Can all jobs be scheduled on a single machine?

2.2 Flow Construction

  • Time slots: discretize into unit slots between min rir_i and max did_i
  • Source → each job: capacity pip_i
  • Each job → eligible slots: capacity 1
  • Each slot → sink: capacity 1
  • Feasible schedule exists iff max flow = pi\sum p_i

3. Baseball Elimination

3.1 Problem

Which teams are mathematically eliminated from playoff contention? Flow construction: For each remaining game between teams ii and jj, create game node gijg_{ij} with edge from source (capacity = games remaining). Each game connects to team nodes (capacity ∞). Team nodes connect to sink with capacity = wins team ii can still have without exceeding team xx's max. Cut interpretation: If min-cut < total remaining games, team xx is eliminated.

3.2 Tracing Example

TeamWinsGames Leftvs. Avs. Bvs. C
A501046
B481046
C471066
D4410550
Can team D (44 wins) still win? Max wins D can achieve = 44 + 10 = 54. But will some other team exceed 54?

4. Project Selection

4.1 Problem

Projects with revenue pip_i (profit if > 0, cost if < 0). Some projects require others as prerequisites. Select feasible set maximizing profit.

4.2 Reduction to Min-Cut

(Diagram)
  • Source → profitable projects: capacity = revenue
  • Costly projects → sink: capacity = |cost|
  • Prerequisite edges: capacity = ∞
  • Selected projects = reachable from source in min-cut

5. Common Pitfalls

Pitfall 1: Wrong Capacity Assignment

The mistake: Setting edge capacities incorrectly, allowing infeasible flows. Correct approach: Each unit of flow should represent one unit of resource (job, match, slot). Verify flow corresponds to valid solution.

Pitfall 2: Missing Intermediate Nodes

The mistake: Connecting source directly to sink without game/job nodes. Correct approach: Model constraints as intermediate nodes. Game nodes ensure each game result is assigned exactly once.

Pitfall 3: Infinite Capacity on Wrong Edges

The mistake: Using ∞ capacities constrain the cut improperly. Correct approach: Only prerequisite edges should have ∞ capacity (must be selected together). Player/slot capacities must be finite.

6. Key Concepts Reference

ApplicationFlow ModelKey Insight
Bipartite matchingUnit capacitiesFlow = matching size
SchedulingJob→slot edgesFeasibility via max flow
Baseball eliminationGame→team nodesMin-cut = elimination proof
Project selectionSource→profit, cost→sinkMax profit = total revenue - min cut
Image segmentationSource=foreground, sink=backgroundMin-cut = optimal segmentation

7. 📝 Practice Questions

Q1: A bipartite graph has U={a,b,c}, V={1,2,3}. Edges: a-1, a-2, b-2, b-3, c-1, c-3. Find maximum matching.
Answer: Max matching = 3. Possible matching: (a,1), (b,2), (c,3). All three vertices on both sides matched (perfect matching). Flow formulation would find this in 3 augmentations. Q2: What does the min-cut in the baseball elimination graph represent?
Answer: The min-cut represents a set of teams that must exceed team x's wins. If Team A and B are on the source side of the cut, ALL remaining games between A and B must go to A or B (cannot go to x's side). The cut capacity = wins A/B must get + remaining games involving them. If this capacity < total remaining games, some wins must go to x's opponents, meaning x is eliminated. Q3: For project selection with profits [5, -3, -2, 4] and prerequisites: 1→3, 2→3, 3→4, find optimal selection.
Answer: Flow model: s→1 (5), s→2 (0 since 2 not profitable... wait, 2 has 0 profit? No -2 is a cost). Actually: P1=5, P2=-3, P3=-2, P4=4. Source connects to P1(5) and P4(4). P2 connects to sink(3), P3 connects to sink(2). Prereq: P1→P3, P2→P3, P3→P4. Min cut determines optimal set. Projects reachable from source in min cut are selected. Q4: How does max flow find the min cut?
Answer: After max flow is found, BFS from source along edges with residual capacity > 0. The reachable set = S side of min cut. T side = all other vertices. The min-cut capacity equals max flow value (max-flow min-cut theorem). This also finds the bottleneck edges. Q5: Can all NP problems be solved with network flow?
Answer: No — flow is in P (solvable in polynomial time). Only problems that can be formulated as flow are efficiently solvable. NP-complete problems (like general TSP, 3SAT) cannot be expressed as pure flow networks without exponential blowup. However, flow is a subroutine in approximation algorithms for some NP-hard problems.

8. 🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.