Agent Work: Homework6
Claude Opus 4.6 · COMP 382: Reasoning about Algorithms
COMP 382: Reasoning about Algorithms
Homework 6
Total Points: 100 (Each problem is worth 20 points)
---
Problem 1: True or False [20 points]
Say whether the following claims are true or false. Justify each of your answers with either a proof or a counterexample.
Part (a)
Any flow graph G has a maximum flow that does not include a cycle in which each edge has positive flow.
Part (b)
If all edges in a graph have distinct capacities, there is a unique maximum flow.
Part (c)
If we multiply all edge capacities in a flow network by a positive number λ, then the minimum cut stays unchanged.
Part (d)
If we add a positive number λ to all edge capacities, then the minimum cut stays unchanged.
---
Problem 2: Flow Reduction [20 points]
You are given a flow network with unit-capacity edges: It consists of a directed graph G = (V, E), a source s ∈ V, and a sink t ∈ V; and capacity cₑ = 1 for every e ∈ E. You are also given a parameter k.
The goal is to delete k edges so as to reduce the maximum s-t flow in G by as much as possible. In other words, you should find a set of edges F ⊆ E so that |F| = k and the maximum s-t flow in G' = (V, E \ F) is as small as possible.
Give a polynomial-time algorithm (k cannot occur in the exponent of the complexity term) to solve this problem.
---
Problem 3: Node Capacities [20 points]
In a standard s-t Maximum Flow problem, we assume edges have capacities, and there is no limit on how much flow is allowed to pass through a node. In this problem, we consider the variant of the MaxFlow problem with node capacities.
Let G = (V, E) be a directed graph, with source s ∈ V, sink t ∈ V, and a non-negative node capacity cᵥ for each node. Given a flow f in this graph, the flow through a node v is defined as f^in(v). We say that a flow is feasible if it satisfies the usual flow-conservation constraints and the node-capacity constraints f^in(v) ≤ cᵥ for all nodes.
Give a polynomial-time algorithm to find an s − t maximum flow in such a node-capacitated network.
---
Problem 4: Station Closing [20 points]
Suppose you are in charge of a rail network connecting a large number of towns. Recently, several cases of a contagious disease have been reported in a town A. Your goal is to close down certain railway stations to prevent the disease from spreading to your hometown B. No trains can pass through a closed station.
To minimize expense, you want to close down as few stations as possible. However, you cannot close the station A, as this would expose you to the disease, and you cannot close the station B, because then you couldn't visit your favorite pub.
Describe and analyze an efficient algorithm, based either on max-flow or min-cut, to find the minimum number of stations that must be closed to block all rail travel from A to B.
The rail network is represented by an undirected graph, with a vertex for each station and an edge for each rail connection between two stations. Two special vertices represent the stations in A and B.
---
Problem 5: Exam Scheduling [20 points]
Consider the following problem of scheduling exams at a university. The university offers n different classes. There are r different rooms on campus and t different time slots in which exams can be offered.
You are given two arrays E[1...n] and S[1...r], where:
- E[i] is the number of students enrolled in the i-th class
- S[j] is the number of seats in the j-th room
At most one final exam can be held in each room during each time slot. Class i can hold its final exam in room j only if E[i] < S[j].
Give an efficient max-flow or min-cut based algorithm to assign a room and a time slot to each class (or report correctly that no such assignment is possible).
State and briefly explain the complexity of your algorithm.
# COMP382 Homework 6
## Student Responses
<!-- Write your solutions below. Add sections for each problem as needed. -->
<!-- Use proper mathematical notation where applicable. -->
[Your solutions here]
COMP382 Homework 6
Student Responses
---
Problem 1: True or False
Part (a)
TRUE.
Proof: Let f be any maximum flow in G. Suppose f contains a directed cycle C in which every edge carries positive flow. Let ε = min{f(e) : e ∈ C} > 0. Define a new flow f' by:
- f'(e) = f(e) − ε for each edge e ∈ C
- f'(e) = f(e) for all other edges
We claim f' is a valid maximum flow with no positive-flow cycle on C:
1. Capacity constraints: For each e ∈ C, f'(e) = f(e) − ε ≥ 0 (by definition of ε) and f'(e) ≤ f(e) ≤ c(e). For edges not on C, nothing changes.
2. Conservation: For any node v on cycle C, exactly one cycle edge enters v and one leaves v. Subtracting ε from both preserves conservation. For nodes not on C, nothing changes.
3. Flow value unchanged: The net flow out of s does not change, because if the cycle passes through s, equal amounts are subtracted from its incoming and outgoing cycle edges. If the cycle does not pass through s, no edges incident to s are modified. Either way, the flow value (net outflow from s) is unchanged. So f' is still a maximum flow.
4. Progress: At least one edge on C (the one achieving the minimum ε) now has flow 0, so C is no longer a cycle with all edges carrying positive flow.
We repeat this process. Each iteration zeros out at least one edge that was previously carrying positive flow, and no new positive-flow edges are created (we only decrease flow). Since |E| is finite, the process terminates in at most |E| iterations, yielding a maximum flow with no directed cycle in which every edge carries positive flow. ∎
Part (b)
FALSE.
Counterexample: Consider the following flow network with all distinct edge capacities:
- s → a, capacity 5
- s → b, capacity 3
- a → b, capacity 2
- a → t, capacity 4
- b → t, capacity 6
All five capacities (2, 3, 4, 5, 6) are distinct. The minimum cut is {s} | {a, b, t} with capacity 5 + 3 = 8, so the maximum flow value is 8.
Since the only edges out of s are s→a (cap 5) and s→b (cap 3), any max flow must have f(s→a) = 5 and f(s→b) = 3.
By conservation at node a: f(s→a) = f(a→t) + f(a→b), so 5 = f(a→t) + f(a→b). By conservation at node b: f(s→b) + f(a→b) = f(b→t), so f(b→t) = 3 + f(a→b).
The parameter f(a→b) can be any value in [1, 2]:
- f(a→b) ≥ 1 because f(a→t) = 5 − f(a→b) ≤ 4 (capacity of a→t).
- f(a→b) ≤ 2 (capacity of a→b).
Two distinct maximum flows (both with value 8):
Flow 1: f(s→a)=5, f(s→b)=3, f(a→b)=1, f(a→t)=4, f(b→t)=4.
Flow 2: f(s→a)=5, f(s→b)=3, f(a→b)=2, f(a→t)=3, f(b→t)=5.
Both satisfy all capacity constraints, both have value 8. Therefore the maximum flow is not unique despite all edge capacities being distinct. ∎
Part (c)
TRUE.
Proof: Let (S, T) be any s-t cut in the original network. Its capacity is:
cap(S, T) = Σ_{(u,v): u∈S, v∈T} c(u,v)
After multiplying all capacities by λ > 0, the new capacity is:
cap'(S, T) = Σ_{(u,v): u∈S, v∈T} λ · c(u,v) = λ · cap(S, T)
Since every cut's capacity is scaled by the same positive factor λ, the relative ordering of cuts by capacity is preserved. In particular, if (S*, T*) was a minimum cut before scaling, then for any other cut (S, T):
cap(S*, T*) ≤ cap(S, T) ⟹ λ · cap(S*, T*) ≤ λ · cap(S, T) ⟹ cap'(S*, T*) ≤ cap'(S, T)
So (S*, T*) remains a minimum cut after scaling. The minimum cut (as a partition of vertices) stays unchanged. ∎
Part (d)
FALSE.
Counterexample: Consider the following flow network:
- s → a, capacity 5
- a → t, capacity 2
- a → b, capacity 2
- b → t, capacity 2
The s-t cuts and their capacities:
| Cut (S \ | T) | Crossing edges | Capacity | # edges |
|---|---|---|---|---|
| {s} \ | {a,b,t} | s→a | 5 | 1 |
| {s,a} \ | {b,t} | a→t, a→b | 2+2 = 4 | 2 |
| {s,b} \ | {a,t} | s→a, b→t | 5+2 = 7 | 2 |
| {s,a,b} \ | {t} | a→t, b→t | 2+2 = 4 | 2 |
The minimum cut is {s,a} | {b,t} (or equivalently {s,a,b} | {t}), with capacity 4 and 2 crossing edges.
Now add λ = 2 to all capacities. New capacities: s→a = 7, a→t = 4, a→b = 4, b→t = 4.
| Cut (S \ | T) | New capacity | Calculation |
|---|---|---|---|
| {s} \ | {a,b,t} | 7 | old cap + λ × 1 edge |
| {s,a} \ | {b,t} | 8 | old cap + λ × 2 edges |
| {s,b} \ | {a,t} | 11 | old cap + λ × 2 edges |
| {s,a,b} \ | {t} | 8 | old cap + λ × 2 edges |
The new minimum cut is {s} | {a,b,t} with capacity 7, which is different from the original minimum cut.
Why this happens: Adding λ to each edge increases a cut's capacity by λ times the number of edges crossing the cut. Cuts with more crossing edges get a larger capacity increase. The original min cut had 2 crossing edges, while the cut {s} had only 1 crossing edge, so adding λ penalizes the original min cut more heavily, eventually making the sparser cut cheaper. ∎
---
Problem 2: Flow Reduction
Algorithm
Input: Unit-capacity flow network G = (V, E) with source s, sink t, and parameter k.
Output: A set F ⊆ E with |F| = k that minimizes the max s-t flow in G' = (V, E \ F).
1. Compute the maximum s-t flow in G using any polynomial-time algorithm (e.g., Ford-Fulkerson with BFS). Let the max flow value be c.
2. Find the minimum s-t cut: perform BFS/DFS from s in the residual graph to find the set S of vertices reachable from s. The min-cut edges are C = {(u,v) ∈ E : u ∈ S, v ∉ S}. Note |C| = c (since all edges have unit capacity).
3. If k ≥ c: set F = C ∪ (any k − c additional edges from E \ C). The new max flow is 0.
4. If k < c: set F = any k edges chosen from C. The new max flow is c − k.
5. Return F.
Correctness
Claim: This algorithm is optimal, i.e., no set of k edge deletions can reduce the max flow below max(0, c − k).
Proof: Consider any set F ⊆ E with |F| = k. For any s-t cut (S, T) in G:
- The new capacity of (S, T) in G' = (V, E \ F) is cap(S,T) − |F ∩ E(S,T)|.
- Since |F ∩ E(S,T)| ≤ |F| = k, the new capacity is ≥ cap(S,T) − k.
- By the max-flow min-cut theorem, the new max flow = min over all cuts of new capacity ≥ min over all cuts of (cap(S,T) − k) = c − k.
So no strategy can reduce the max flow below max(0, c − k). Our algorithm achieves exactly this bound by removing k edges from the original min cut (which had capacity c), reducing its capacity to c − k. All other cuts originally had capacity ≥ c, and losing at most k edges, their new capacity is ≥ c − k. So the new min cut is exactly max(0, c − k). ∎
Complexity
- Step 1: Computing max flow in a unit-capacity network using Ford-Fulkerson with BFS takes O(V · E) time (at most V augmentations, each requiring O(E) BFS).
- Step 2: BFS in the residual graph takes O(V + E).
- Steps 3–4: Selecting edges takes O(k) ≤ O(E).
Total: O(VE), which is polynomial in the input size. Note that k does not appear in the exponent.
---
Problem 3: Node Capacities
Reduction to Standard Max Flow
We reduce the node-capacitated problem to a standard edge-capacitated max flow problem using node splitting.
Construction of G':
Given G = (V, E) with node capacities c_v, construct a new directed graph G' = (V', E') as follows:
1. Node splitting: For each node v ∈ V, create two nodes v_in and v_out in G'. Add a directed edge (v_in, v_out) with capacity c_v. This internal edge enforces the node capacity constraint.
2. Edge transformation: For each directed edge (u, v) ∈ E, add a directed edge (u_out, v_in) with capacity ∞ (in practice, use a sufficiently large value such as Σ_v c_v). These edges are unconstrained since the original problem has no edge capacities — the only constraints come from node capacities.
3. Source and sink: The source in G' is s_in and the sink is t_out.
Algorithm:
1. Construct G' as described above. 2. Run any standard max-flow algorithm (e.g., Edmonds-Karp) on G' from s_in to t_out. 3. The max flow value in G' equals the max flow value in the node-capacitated network G. 4. The flow on each original edge (u, v) is given by the flow on (u_out, v_in) in G'.
Correctness
We show a one-to-one correspondence between feasible flows in G and feasible flows in G':
G → G': Given a feasible flow f in G, define flow f' in G' by:
- f'(v_in, v_out) = f^in(v) for each v (the total flow entering v).
- f'(u_out, v_in) = f(u, v) for each edge (u, v) ∈ E.
Conservation holds at each v_in (total in from edges = flow to v_out = f^in(v)) and at each v_out (flow from v_in = total out on edges from v). The capacity constraint f'(v_in, v_out) = f^in(v) ≤ c_v is satisfied by feasibility in G.
G' → G: Given a feasible flow f' in G', define f(u,v) = f'(u_out, v_in) for each (u,v) ∈ E. Conservation in G follows from conservation in G'. The node capacity constraint f^in(v) = f'(v_in, v_out) ≤ c_v is satisfied by the edge capacity in G'.
Since the correspondence preserves flow value (net outflow from s_in in G' equals net outflow from s in G), the max flows are equal.
Complexity
- G' has |V'| = 2|V| nodes and |E'| = |V| + |E| edges.
- Using Edmonds-Karp: O(|V'| · |E'|²) = O(|V| · (|V| + |E|)²).
This is polynomial in the input size. ∎
---
Problem 4: Station Closing
Problem Formulation
This is a minimum vertex cut problem: find the minimum number of vertices (excluding A and B) whose removal disconnects A from B in an undirected graph.
We reduce it to a max-flow problem using node splitting.
Algorithm
Input: Undirected graph G = (V, E) with special vertices A and B.
Step 1: Construct directed flow network G'.
1. Direct the graph: Replace each undirected edge {u, v} with two directed edges (u, v) and (v, u).
2. Node splitting: For each vertex v ∈ V: - Create two nodes v_in and v_out. - If v ∈ {A, B}: add edge (v_in → v_out) with capacity ∞ (these stations cannot be closed). - Otherwise: add edge (v_in → v_out) with capacity 1 (closing station v costs 1 unit).
3. Edge transformation: For each directed edge (u, v) from Step 1, add edge (u_out → v_in) with capacity ∞. (Edges are not the bottleneck; only stations/nodes can be closed.)
Step 2: Compute max flow from A_out to B_in in G'.
Run any standard max-flow algorithm (e.g., Dinic's algorithm) on G' with source A_out and sink B_in.
Step 3: The max flow value equals the minimum number of stations to close.
Step 4: Identify which stations to close.
In the residual graph after computing max flow, run BFS/DFS from A_out to find the set R of reachable vertices. For each vertex v ∉ {A, B}: if v_in ∈ R but v_out ∉ R, then station v must be closed (the edge v_in → v_out is saturated and lies on the min cut).
Correctness
By the max-flow min-cut theorem, the max flow from A_out to B_in equals the min cut capacity. In G', the only finite-capacity edges are the internal edges (v_in → v_out) with capacity 1 for v ∉ {A, B}. All other edges have capacity ∞ and thus cannot be in a finite min cut.
Therefore, the min cut consists entirely of internal node edges, each with capacity 1. The min cut value equals the number of such edges, which corresponds to the minimum number of stations (other than A and B) that must be closed to disconnect A from B.
By Menger's theorem (vertex version), this also equals the maximum number of internally vertex-disjoint A-B paths.
Complexity
- G' has O(|V|) nodes and O(|V| + |E|) edges.
- The max flow value is at most |V| (bounded by unit-capacity internal edges).
- Using Ford-Fulkerson with BFS: O(max_flow × |E'|) = O(|V| · (|V| + |E|)) = O(V² + VE).
- Using Dinic's algorithm on this unit-capacity-like network: O(E√V) where E = O(|V| + |E|).
---
Problem 5: Exam Scheduling
Flow Network Construction
Input: n classes with enrollments E[1..n], r rooms with capacities S[1..r], and t time slots.
Construct a flow network G' = (V', E') as follows:
1. Source node s.
2. Class nodes c_1, c_2, ..., c_n (one per class).
3. Room nodes r_1, r_2, ..., r_r (one per room).
4. Sink node t.
5. Edges: - s → c_i with capacity 1 for each class i (each class needs exactly one exam slot). - c_i → r_j with capacity 1 for each class i and room j such that E[i] < S[j] (class i fits in room j). - r_j → t with capacity t (the number of time slots) for each room j (each room can host at most t exams, one per time slot).
Algorithm
1. Construct the flow network G' as described above. 2. Compute the max flow from s to t using any standard algorithm (e.g., Ford-Fulkerson with BFS). 3. If max flow = n: A valid assignment exists. - For each class i, it is assigned to the room j where f(c_i, r_j) = 1. - For each room j, collect the set of classes assigned to it. Since at most t classes are assigned to room j (by the capacity-t edge), assign each class a distinct time slot from {1, 2, ..., t} in any order. 4. If max flow < n: No valid assignment exists. Report that scheduling is impossible.
Correctness
Valid flow → valid schedule: If the max flow equals n, every class sends exactly 1 unit of flow to some room. The capacity-1 edges from s ensure each class is assigned to exactly one room. The edge c_i → r_j exists only when E[i] < S[j], so the room is large enough. The capacity-t edge from r_j to sink ensures at most t classes are assigned to room j. Since there are t time slots, we can always assign distinct time slots to the ≤ t classes sharing a room.
Valid schedule → valid flow: Given a valid schedule, define flow: f(s, c_i) = 1, f(c_i, r_j) = 1 if class i is in room j, and f(r_j, t) = number of classes in room j. This is a valid flow of value n.
Therefore, a valid assignment exists if and only if the max flow equals n.
Time slot assignment is always feasible: Each room has at most t classes (enforced by the r_j → t capacity), and there are t time slots, so a valid one-to-one assignment of classes to time slots within each room always exists.
Complexity
- Nodes: |V'| = 2 + n + r = O(n + r).
- Edges: |E'| = n + (edges from classes to rooms) + r ≤ n + nr + r = O(nr).
- Max flow value: At most n.
- Ford-Fulkerson with BFS: O(max_flow × |E'|) = O(n × nr) = O(n²r).
- Time slot assignment: O(n) (linear scan over classes grouped by room).
Total complexity: O(n²r), which is polynomial in the input size.
Problem 1: True or False
Score: 20/20 points
Assessment:
Part (a): TRUE — 5/5
Approach: The student provides a detailed constructive proof showing how to eliminate positive-flow cycles by subtracting ε (the minimum flow on the cycle) from every cycle edge.
Strengths:
- Carefully verifies all four properties: capacity constraints, conservation, unchanged flow value, and termination.
- The termination argument (each iteration zeroes out at least one edge, bounded by |E|) is a nice addition beyond what the reference requires.
Errors/Gaps: None.
---
Part (b): FALSE — 5/5
Approach: Constructs a network with 4 nodes and 5 edges having distinct capacities (2, 3, 4, 5, 6) and explicitly exhibits two distinct maximum flows.
Strengths:
- The counterexample is concrete, verified with exact flow values, and all capacity constraints are checked.
- The parameterization of f(a→b) ∈ [1, 2] clearly demonstrates a continuum of max flows.
Errors/Gaps: None.
---
Part (c): TRUE — 5/5
Approach: Clean algebraic proof that cap'(S,T) = λ · cap(S,T), preserving the ordering of cuts.
Strengths:
- The proof is rigorous and concise, using the formal definition of cut capacity.
Errors/Gaps: None.
---
Part (d): FALSE — 5/5
Approach: Provides a concrete counterexample with λ = 2, enumerating all cuts before and after adding λ. Includes an excellent intuitive explanation of *why* the min cut changes.
Strengths:
- All cuts are enumerated and verified.
- The insight that adding λ increases each cut by λ × (number of crossing edges), penalizing denser cuts more heavily, is a particularly clear explanation.
Errors/Gaps: None.
---
Problem 2: Flow Reduction
Score: 20/20 points
Assessment:
Approach: Compute the max flow / min cut, then remove k edges from the min cut. If k ≥ c (min cut size), remove all min cut edges to reduce flow to 0.
Strengths:
- Algorithm is identical to the reference solution and clearly stated.
- Optimality proof is rigorous: for any set F of k deletions, any cut loses at most k capacity, so the new max flow is ≥ c − k. The algorithm achieves this lower bound exactly.
- Complexity analysis correctly exploits the unit-capacity structure: O(VE) via Ford-Fulkerson with BFS on a unit-capacity graph.
Errors/Gaps: None.
Rubric Breakdown:
- Algorithm description: 8/8 — Clear polynomial-time algorithm
- Correctness/optimality proof: 8/8 — Both directions (achievability and lower bound) shown
- Complexity analysis: 4/4 — Correctly identifies O(VE), k not in exponent
---
Problem 3: Node Capacities
Score: 20/20 points
Assessment:
Approach: Standard node-splitting reduction: each node v becomes v_in and v_out connected by an edge of capacity c_v. Original edges (u,v) become (u_out, v_in) with infinite capacity.
Strengths:
- Construction matches the reference solution.
- Correctness proof explicitly shows both directions (G → G' and G' → G) of the flow correspondence, which is exactly what's needed.
- The student splits all nodes (including s and t), using s_in as source and t_out as sink. This is actually slightly more general than the reference (which excludes s and t), and correctly handles node capacities on s and t as well.
Errors/Gaps: None.
Rubric Breakdown:
- Construction: 8/8 — Correct node-splitting with proper capacities
- Correctness (both directions): 8/8 — Both flow correspondences proven
- Complexity analysis: 4/4 — Correctly computed as O(|V| · (|V| + |E|)²)
---
Problem 4: Station Closing
Score: 20/20 points
Assessment:
Approach: Reduces the minimum vertex cut problem to max flow via node splitting. Internal edges for A and B have infinite capacity (cannot be closed); all others have capacity 1. External edges have infinite capacity.
Strengths:
- Correctly handles the undirected graph by replacing each edge with two directed edges.
- Properly sets A and B capacities to ∞ to enforce the constraint that they cannot be closed.
- Identifies the closed stations from the min cut: v_in ∈ R but v_out ∉ R.
- Correctness argument via max-flow min-cut is sound — finite-capacity edges are exactly the internal node edges.
- Nice reference to Menger's theorem for additional context.
- Provides two complexity analyses (Ford-Fulkerson and Dinic's).
Errors/Gaps: None.
Rubric Breakdown:
- Construction: 8/8 — Correct node splitting with proper capacity assignments
- Correctness argument: 8/8 — Min cut = min vertex cut, well justified
- Complexity and station identification: 4/4 — Correct
---
Problem 5: Exam Scheduling
Score: 20/20 points
Assessment:
Approach: Flow network with class nodes and room nodes (no explicit time slot nodes). Edges: s → c_i (cap 1), c_i → r_j (cap 1, when E[i] < S[j]), r_j → sink (cap t). Time slots assigned in post-processing.
Strengths:
- This is actually a simpler and more elegant construction than the reference solution, which uses explicit time slot nodes. The student's approach is correct because:
- Each room gets at most t classes (enforced by the capacity-t edge to sink). - Since there are t time slots and at most t classes per room, distinct time slots can always be assigned greedily.
- Correctness proof covers both directions: valid flow → valid schedule and valid schedule → valid flow.
- The observation about time slot feasibility is explicitly justified.
- Complexity O(n²r) is correctly computed and is tighter than the reference's O((n+r+t)(nr+rt)²).
Errors/Gaps: None. The naming conflict between sink node "t" and the number of time slots "t" is a minor style issue but the meaning is always clear from context.
Rubric Breakdown:
- Flow network construction: 8/8 — Valid alternative construction
- Correctness proof: 8/8 — Both directions shown, time slot feasibility justified
- Complexity analysis: 4/4 — Correctly computed as O(n²r)
---
Overall Summary
| Problem | Score | Notes |
|---|---|---|
| 1 | 20/20 | All four parts correct with rigorous proofs and clear counterexamples |
| 2 | 20/20 | Correct algorithm with tight optimality proof |
| 3 | 20/20 | Clean node-splitting reduction with both directions of correspondence |
| 4 | 20/20 | Correct vertex cut reduction with station identification |
| 5 | 20/20 | Elegant simplified construction (no time nodes), correct |
| Total | 100/100 |
General Comments:
This is an outstanding submission. Every problem is solved correctly with clear, rigorous justifications. The student demonstrates deep understanding of network flow concepts — max-flow min-cut theorem, node splitting, and flow reductions. Several answers go beyond the reference solution in quality: Problem 1(a) includes a termination argument, Problem 1(d) provides intuition for *why* the result holds, and Problem 5 uses a simpler construction than the reference while remaining fully correct. The writing is exceptionally well-organized with clean mathematical notation throughout.
Total: 100/100
diff --git a/writeup.md b/writeup.md
index eda66f5..f06465d 100644
--- a/writeup.md
+++ b/writeup.md
@@ -2,8 +2,299 @@
## Student Responses
-<!-- Write your solutions below. Add sections for each problem as needed. -->
-<!-- Use proper mathematical notation where applicable. -->
+---
-[Your solutions here]
+## Problem 1: True or False
+### Part (a)
+
+**TRUE.**
+
+**Proof:** Let f be any maximum flow in G. Suppose f contains a directed cycle C in which every edge carries positive flow. Let ε = min{f(e) : e ∈ C} > 0. Define a new flow f' by:
+
+- f'(e) = f(e) − ε for each edge e ∈ C
+- f'(e) = f(e) for all other edges
+
+We claim f' is a valid maximum flow with no positive-flow cycle on C:
+
+1. **Capacity constraints:** For each e ∈ C, f'(e) = f(e) − ε ≥ 0 (by definition of ε) and f'(e) ≤ f(e) ≤ c(e). For edges not on C, nothing changes.
+
+2. **Conservation:** For any node v on cycle C, exactly one cycle edge enters v and one leaves v. Subtracting ε from both preserves conservation. For nodes not on C, nothing changes.
+
+3. **Flow value unchanged:** The net flow out of s does not change, because if the cycle passes through s, equal amounts are subtracted from its incoming and outgoing cycle edges. If the cycle does not pass through s, no edges incident to s are modified. Either way, the flow value (net outflow from s) is unchanged. So f' is still a maximum flow.
+
+4. **Progress:** At least one edge on C (the one achieving the minimum ε) now has flow 0, so C is no longer a cycle with all edges carrying positive flow.
+
+We repeat this process. Each iteration zeros out at least one edge that was previously carrying positive flow, and no new positive-flow edges are created (we only decrease flow). Since |E| is finite, the process terminates in at most |E| iterations, yielding a maximum flow with no directed cycle in which every edge carries positive flow. ∎
+
+### Part (b)
+
+**FALSE.**
+
+**Counterexample:** Consider the following flow network with all distinct edge capacities:
+
+- s → a, capacity 5
+- s → b, capacity 3
+- a → b, capacity 2
+- a → t, capacity 4
+- b → t, capacity 6
+
+All five capacities (2, 3, 4, 5, 6) are distinct. The minimum cut is {s} | {a, b, t} with capacity 5 + 3 = 8, so the maximum flow value is 8.
+
+Since the only edges out of s are s→a (cap 5) and s→b (cap 3), any max flow must have f(s→a) = 5 and f(s→b) = 3.
+
+By conservation at node a: f(s→a) = f(a→t) + f(a→b), so 5 = f(a→t) + f(a→b).
+By conservation at node b: f(s→b) + f(a→b) = f(b→t), so f(b→t) = 3 + f(a→b).
+
+The parameter f(a→b) can be any value in [1, 2]:
+- f(a→b) ≥ 1 because f(a→t) = 5 − f(a→b) ≤ 4 (capacity of a→t).
+- f(a→b) ≤ 2 (capacity of a→b).
+
+Two distinct maximum flows (both with value 8):
+
+**Flow 1:** f(s→a)=5, f(s→b)=3, f(a→b)=1, f(a→t)=4, f(b→t)=4.
+
+**Flow 2:** f(s→a)=5, f(s→b)=3, f(a→b)=2, f(a→t)=3, f(b→t)=5.
+
+Both satisfy all capacity constraints, both have value 8. Therefore the maximum flow is not unique despite all edge capacities being distinct. ∎
+
+### Part (c)
+
+**TRUE.**
+
+**Proof:** Let (S, T) be any s-t cut in the original network. Its capacity is:
+
+cap(S, T) = Σ_{(u,v): u∈S, v∈T} c(u,v)
+
+After multiplying all capacities by λ > 0, the new capacity is:
+
+cap'(S, T) = Σ_{(u,v): u∈S, v∈T} λ · c(u,v) = λ · cap(S, T)
+
+Since every cut's capacity is scaled by the same positive factor λ, the relative ordering of cuts by capacity is preserved. In particular, if (S*, T*) was a minimum cut before scaling, then for any other cut (S, T):
+
+cap(S*, T*) ≤ cap(S, T) ⟹ λ · cap(S*, T*) ≤ λ · cap(S, T) ⟹ cap'(S*, T*) ≤ cap'(S, T)
+
+So (S*, T*) remains a minimum cut after scaling. The minimum cut (as a partition of vertices) stays unchanged. ∎
+
+### Part (d)
+
+**FALSE.**
+
+**Counterexample:** Consider the following flow network:
+
+- s → a, capacity 5
+- a → t, capacity 2
+- a → b, capacity 2
+- b → t, capacity 2
+
+The s-t cuts and their capacities:
+
+| Cut (S \| T) | Crossing edges | Capacity | # edges |
+|---|---|---|---|
+| {s} \| {a,b,t} | s→a | 5 | 1 |
+| {s,a} \| {b,t} | a→t, a→b | 2+2 = 4 | 2 |
+| {s,b} \| {a,t} | s→a, b→t | 5+2 = 7 | 2 |
+| {s,a,b} \| {t} | a→t, b→t | 2+2 = 4 | 2 |
+
+The minimum cut is {s,a} | {b,t} (or equivalently {s,a,b} | {t}), with capacity **4** and **2 crossing edges**.
+
+Now add λ = 2 to all capacities. New capacities: s→a = 7, a→t = 4, a→b = 4, b→t = 4.
+
+| Cut (S \| T) | New capacity | Calculation |
+|---|---|---|
+| {s} \| {a,b,t} | 7 | old cap + λ × 1 edge |
+| {s,a} \| {b,t} | 8 | old cap + λ × 2 edges |
+| {s,b} \| {a,t} | 11 | old cap + λ × 2 edges |
+| {s,a,b} \| {t} | 8 | old cap + λ × 2 edges |
+
+The new minimum cut is {s} | {a,b,t} with capacity **7**, which is different from the original minimum cut.
+
+**Why this happens:** Adding λ to each edge increases a cut's capacity by λ times the number of edges crossing the cut. Cuts with more crossing edges get a larger capacity increase. The original min cut had 2 crossing edges, while the cut {s} had only 1 crossing edge, so adding λ penalizes the original min cut more heavily, eventually making the sparser cut cheaper. ∎
+
+---
+
+## Problem 2: Flow Reduction
+
+### Algorithm
+
+**Input:** Unit-capacity flow network G = (V, E) with source s, sink t, and parameter k.
+
+**Output:** A set F ⊆ E with |F| = k that minimizes the max s-t flow in G' = (V, E \ F).
+
+1. Compute the maximum s-t flow in G using any polynomial-time algorithm (e.g., Ford-Fulkerson with BFS). Let the max flow value be c.
+
+2. Find the minimum s-t cut: perform BFS/DFS from s in the residual graph to find the set S of vertices reachable from s. The min-cut edges are C = {(u,v) ∈ E : u ∈ S, v ∉ S}. Note |C| = c (since all edges have unit capacity).
+
+3. If k ≥ c: set F = C ∪ (any k − c additional edges from E \ C). The new max flow is 0.
+
+4. If k < c: set F = any k edges chosen from C. The new max flow is c − k.
+
+5. Return F.
+
+### Correctness
+
+**Claim:** This algorithm is optimal, i.e., no set of k edge deletions can reduce the max flow below max(0, c − k).
+
+**Proof:** Consider any set F ⊆ E with |F| = k. For any s-t cut (S, T) in G:
+
+- The new capacity of (S, T) in G' = (V, E \ F) is cap(S,T) − |F ∩ E(S,T)|.
+- Since |F ∩ E(S,T)| ≤ |F| = k, the new capacity is ≥ cap(S,T) − k.
+- By the max-flow min-cut theorem, the new max flow = min over all cuts of new capacity ≥ min over all cuts of (cap(S,T) − k) = c − k.
+
+So no strategy can reduce the max flow below max(0, c − k). Our algorithm achieves exactly this bound by removing k edges from the original min cut (which had capacity c), reducing its capacity to c − k. All other cuts originally had capacity ≥ c, and losing at most k edges, their new capacity is ≥ c − k. So the new min cut is exactly max(0, c − k). ∎
+
+### Complexity
+
+- Step 1: Computing max flow in a unit-capacity network using Ford-Fulkerson with BFS takes O(V · E) time (at most V augmentations, each requiring O(E) BFS).
+- Step 2: BFS in the residual graph takes O(V + E).
+- Steps 3–4: Selecting edges takes O(k) ≤ O(E).
+
+**Total: O(VE)**, which is polynomial in the input size. Note that k does not appear in the exponent.
+
+---
+
+## Problem 3: Node Capacities
+
+### Reduction to Standard Max Flow
+
+We reduce the node-capacitated problem to a standard edge-capacitated max flow problem using **node splitting**.
+
+**Construction of G':**
+
+Given G = (V, E) with node capacities c_v, construct a new directed graph G' = (V', E') as follows:
+
+1. **Node splitting:** For each node v ∈ V, create two nodes v_in and v_out in G'. Add a directed edge (v_in, v_out) with capacity c_v. This internal edge enforces the node capacity constraint.
+
+2. **Edge transformation:** For each directed edge (u, v) ∈ E, add a directed edge (u_out, v_in) with capacity ∞ (in practice, use a sufficiently large value such as Σ_v c_v). These edges are unconstrained since the original problem has no edge capacities — the only constraints come from node capacities.
+
+3. **Source and sink:** The source in G' is s_in and the sink is t_out.
+
+**Algorithm:**
+
+1. Construct G' as described above.
+2. Run any standard max-flow algorithm (e.g., Edmonds-Karp) on G' from s_in to t_out.
+3. The max flow value in G' equals the max flow value in the node-capacitated network G.
+4. The flow on each original edge (u, v) is given by the flow on (u_out, v_in) in G'.
+
+### Correctness
+
+We show a one-to-one correspondence between feasible flows in G and feasible flows in G':
+
+**G → G':** Given a feasible flow f in G, define flow f' in G' by:
+- f'(v_in, v_out) = f^in(v) for each v (the total flow entering v).
+- f'(u_out, v_in) = f(u, v) for each edge (u, v) ∈ E.
+
+Conservation holds at each v_in (total in from edges = flow to v_out = f^in(v)) and at each v_out (flow from v_in = total out on edges from v). The capacity constraint f'(v_in, v_out) = f^in(v) ≤ c_v is satisfied by feasibility in G.
+
+**G' → G:** Given a feasible flow f' in G', define f(u,v) = f'(u_out, v_in) for each (u,v) ∈ E. Conservation in G follows from conservation in G'. The node capacity constraint f^in(v) = f'(v_in, v_out) ≤ c_v is satisfied by the edge capacity in G'.
+
+Since the correspondence preserves flow value (net outflow from s_in in G' equals net outflow from s in G), the max flows are equal.
+
+### Complexity
+
+- G' has |V'| = 2|V| nodes and |E'| = |V| + |E| edges.
+- Using Edmonds-Karp: O(|V'| · |E'|²) = O(|V| · (|V| + |E|)²).
+
+This is polynomial in the input size. ∎
+
+---
+
+## Problem 4: Station Closing
+
+### Problem Formulation
+
+This is a **minimum vertex cut** problem: find the minimum number of vertices (excluding A and B) whose removal disconnects A from B in an undirected graph.
+
+We reduce it to a max-flow problem using node splitting.
+
+### Algorithm
+
+**Input:** Undirected graph G = (V, E) with special vertices A and B.
+
+**Step 1: Construct directed flow network G'.**
+
+1. **Direct the graph:** Replace each undirected edge {u, v} with two directed edges (u, v) and (v, u).
+
+2. **Node splitting:** For each vertex v ∈ V:
+ - Create two nodes v_in and v_out.
+ - If v ∈ {A, B}: add edge (v_in → v_out) with capacity ∞ (these stations cannot be closed).
+ - Otherwise: add edge (v_in → v_out) with capacity 1 (closing station v costs 1 unit).
+
+3. **Edge transformation:** For each directed edge (u, v) from Step 1, add edge (u_out → v_in) with capacity ∞. (Edges are not the bottleneck; only stations/nodes can be closed.)
+
+**Step 2: Compute max flow from A_out to B_in in G'.**
+
+Run any standard max-flow algorithm (e.g., Dinic's algorithm) on G' with source A_out and sink B_in.
+
+**Step 3: The max flow value equals the minimum number of stations to close.**
+
+**Step 4: Identify which stations to close.**
+
+In the residual graph after computing max flow, run BFS/DFS from A_out to find the set R of reachable vertices. For each vertex v ∉ {A, B}: if v_in ∈ R but v_out ∉ R, then station v must be closed (the edge v_in → v_out is saturated and lies on the min cut).
+
+### Correctness
+
+By the max-flow min-cut theorem, the max flow from A_out to B_in equals the min cut capacity. In G', the only finite-capacity edges are the internal edges (v_in → v_out) with capacity 1 for v ∉ {A, B}. All other edges have capacity ∞ and thus cannot be in a finite min cut.
+
+Therefore, the min cut consists entirely of internal node edges, each with capacity 1. The min cut value equals the number of such edges, which corresponds to the minimum number of stations (other than A and B) that must be closed to disconnect A from B.
+
+By Menger's theorem (vertex version), this also equals the maximum number of internally vertex-disjoint A-B paths.
+
+### Complexity
+
+- G' has O(|V|) nodes and O(|V| + |E|) edges.
+- The max flow value is at most |V| (bounded by unit-capacity internal edges).
+- Using Ford-Fulkerson with BFS: O(max_flow × |E'|) = O(|V| · (|V| + |E|)) = **O(V² + VE)**.
+- Using Dinic's algorithm on this unit-capacity-like network: **O(E√V)** where E = O(|V| + |E|).
+
+---
+
+## Problem 5: Exam Scheduling
+
+### Flow Network Construction
+
+**Input:** n classes with enrollments E[1..n], r rooms with capacities S[1..r], and t time slots.
+
+Construct a flow network G' = (V', E') as follows:
+
+1. **Source node** s.
+
+2. **Class nodes** c_1, c_2, ..., c_n (one per class).
+
+3. **Room nodes** r_1, r_2, ..., r_r (one per room).
+
+4. **Sink node** t.
+
+5. **Edges:**
+ - **s → c_i** with capacity 1 for each class i (each class needs exactly one exam slot).
+ - **c_i → r_j** with capacity 1 for each class i and room j such that E[i] < S[j] (class i fits in room j).
+ - **r_j → t** with capacity t (the number of time slots) for each room j (each room can host at most t exams, one per time slot).
+
+### Algorithm
+
+1. Construct the flow network G' as described above.
+2. Compute the max flow from s to t using any standard algorithm (e.g., Ford-Fulkerson with BFS).
+3. **If max flow = n:** A valid assignment exists.
+ - For each class i, it is assigned to the room j where f(c_i, r_j) = 1.
+ - For each room j, collect the set of classes assigned to it. Since at most t classes are assigned to room j (by the capacity-t edge), assign each class a distinct time slot from {1, 2, ..., t} in any order.
+4. **If max flow < n:** No valid assignment exists. Report that scheduling is impossible.
+
+### Correctness
+
+**Valid flow → valid schedule:** If the max flow equals n, every class sends exactly 1 unit of flow to some room. The capacity-1 edges from s ensure each class is assigned to exactly one room. The edge c_i → r_j exists only when E[i] < S[j], so the room is large enough. The capacity-t edge from r_j to sink ensures at most t classes are assigned to room j. Since there are t time slots, we can always assign distinct time slots to the ≤ t classes sharing a room.
+
+**Valid schedule → valid flow:** Given a valid schedule, define flow: f(s, c_i) = 1, f(c_i, r_j) = 1 if class i is in room j, and f(r_j, t) = number of classes in room j. This is a valid flow of value n.
+
+Therefore, a valid assignment exists if and only if the max flow equals n.
+
+**Time slot assignment is always feasible:** Each room has at most t classes (enforced by the r_j → t capacity), and there are t time slots, so a valid one-to-one assignment of classes to time slots within each room always exists.
+
+### Complexity
+
+- **Nodes:** |V'| = 2 + n + r = O(n + r).
+- **Edges:** |E'| = n + (edges from classes to rooms) + r ≤ n + nr + r = O(nr).
+- **Max flow value:** At most n.
+- **Ford-Fulkerson with BFS:** O(max_flow × |E'|) = O(n × nr) = **O(n²r)**.
+- **Time slot assignment:** O(n) (linear scan over classes grouped by room).
+
+**Total complexity: O(n²r)**, which is polynomial in the input size.
Sub-Model Usage
| Model | Input | Output | Cache Read | Cost |
|---|---|---|---|---|
| claude-opus-4-6 | 5 | 31.3K | 133.8K | $1.14 |
BSCS Bench