Step 1 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 0/10 Edge from node S to node B 0/8 Edge from node A to node B 0/5 Edge from node A to node C 0/7 Edge from node B to node D 0/10 Edge from node C to node D 0/3 Edge from node C to node T 0/9 Edge from node D to node T 0/12 S A B C D T total_flow 0 path --- bottleneck --- State Flow network: each edge shows flow/capacity . All flows start at 0. Goal: maximize flow from S S S to T T T .
Step 2 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 0/10 Edge from node S to node B 0/8 Edge from node A to node B 0/5 Edge from node A to node C 0/7 Edge from node B to node D 0/10 Edge from node C to node D 0/3 Edge from node C to node T 0/9 Edge from node D to node T 0/12 S A B C D T total_flow 0 path S-A-C-T bottleneck --- State Iteration 1: BFS from S S S finds shortest path S → A → C → T S \to A \to C \to T S → A → C → T .
Step 3 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 0/10 Edge from node S to node B 0/8 Edge from node A to node B 0/5 Edge from node A to node C 0/7 Edge from node B to node D 0/10 Edge from node C to node D 0/3 Edge from node C to node T 0/9 Edge from node D to node T 0/12 S A B C D T total_flow 0 path S-A-C-T bottleneck 7 State Bottleneck = min ( 10 , 7 , 9 ) = 7 = \min(10, 7, 9) = 7 = min ( 10 , 7 , 9 ) = 7 . Edge A → C A \to C A → C (cap 7) is the bottleneck.
Step 4 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 7/10 Edge from node S to node B 0/8 Edge from node A to node B 0/5 Edge from node A to node C 7/7 Edge from node B to node D 0/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 0/12 S A B C D T total_flow 7 path S-A-C-T bottleneck 7 State Push 7 units. Update flow on each edge. A → C A \to C A → C is now saturated (7/7).
Step 5 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 7/10 Edge from node S to node B 0/8 Edge from node A to node B 0/5 Edge from node A to node C 7/7 Edge from node B to node D 0/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 0/12 S A B C D T total_flow 7 path S-B-D-T bottleneck --- State Iteration 2: BFS. A → C A \to C A → C saturated, so BFS finds S → B → D → T S \to B \to D \to T S → B → D → T .
Step 6 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 7/10 Edge from node S to node B 0/8 Edge from node A to node B 0/5 Edge from node A to node C 7/7 Edge from node B to node D 0/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 0/12 S A B C D T total_flow 7 path S-B-D-T bottleneck 8 State Bottleneck = min ( 8 , 10 , 12 ) = 8 = \min(8, 10, 12) = 8 = min ( 8 , 10 , 12 ) = 8 . Edge S → B S \to B S → B (cap 8) is the bottleneck.
Step 7 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 7/10 Edge from node S to node B 8/8 Edge from node A to node B 0/5 Edge from node A to node C 7/7 Edge from node B to node D 8/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 8/12 S A B C D T total_flow 15 path S-B-D-T bottleneck 8 State Push 8 units. S → B S \to B S → B saturated (8/8).
Step 8 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 7/10 Edge from node S to node B 8/8 Edge from node A to node B 0/5 Edge from node A to node C 7/7 Edge from node B to node D 8/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 8/12 S A B C D T total_flow 15 path S-A-B-D-T bottleneck --- State Iteration 3: S → B S \to B S → B saturated. Only S → A S \to A S → A (residual 10 − 7 = 3 10-7=3 10 − 7 = 3 ) leaves S S S . BFS: S → A → B → D → T S \to A \to B \to D \to T S → A → B → D → T .
Step 9 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 7/10 Edge from node S to node B 8/8 Edge from node A to node B 0/5 Edge from node A to node C 7/7 Edge from node B to node D 8/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 8/12 S A B C D T total_flow 15 path S-A-B-D-T bottleneck 2 State Residual: S → A S \to A S → A : 3, A → B A \to B A → B : 5, B → D B \to D B → D : 2, D → T D \to T D → T : 4. Bottleneck = 2 = 2 = 2 at B → D B \to D B → D .
Step 10 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 9/10 Edge from node S to node B 8/8 Edge from node A to node B 2/5 Edge from node A to node C 7/7 Edge from node B to node D 10/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 10/12 S A B C D T total_flow 17 path S-A-B-D-T bottleneck 2 State Push 2 units. B → D B \to D B → D now saturated (10/10).
Step 11 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 9/10 Edge from node S to node B 8/8 Edge from node A to node B 2/5 Edge from node A to node C 7/7 Edge from node B to node D 10/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 10/12 S A B C D T total_flow 17 path searching... bottleneck --- State Iteration 4: S → A S \to A S → A has 1 residual. A → C A \to C A → C saturated, A → B A \to B A → B has 3. But B → D B \to D B → D saturated — dead end via B B B . Need residual graph : reverse edge C → A C \to A C → A has 7 capacity (undo A → C A \to C A → C flow).
Step 12 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 9/10 Edge from node S to node B 8/8 Edge from node A to node B 2/5 Edge from node A to node C 7/7 Edge from node B to node D 10/10 Edge from node C to node D 0/3 Edge from node C to node T 7/9 Edge from node D to node T 10/12 S A B C D T total_flow 17 path S-A-[rev]C-D-T bottleneck 1 State Residual path found: S → A S \to A S → A (1) → \to → reverse A → C A \to C A → C (7) → C → D \to C \to D → C → D (3) → D → T \to D \to T → D → T (2). Bottleneck = min ( 1 , 7 , 3 , 2 ) = 1 = \min(1,7,3,2) = 1 = min ( 1 , 7 , 3 , 2 ) = 1 .
Step 13 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 10/10 Edge from node S to node B 8/8 Edge from node A to node B 2/5 Edge from node A to node C 6/7 Edge from node B to node D 10/10 Edge from node C to node D 1/3 Edge from node C to node T 7/9 Edge from node D to node T 11/12 S A B C D T total_flow 18 path S-A-[rev]C-D-T bottleneck 1 State Push 1 unit via residual. A → C A \to C A → C flow decreases 7 → 6 7 \to 6 7 → 6 (reverse edge used). S → A S \to A S → A : 10/10 (saturated!). Total = 18 = 18 = 18 .
Step 14 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 10/10 Edge from node S to node B 8/8 Edge from node A to node B 2/5 Edge from node A to node C 6/7 Edge from node B to node D 10/10 Edge from node C to node D 1/3 Edge from node C to node T 7/9 Edge from node D to node T 11/12 S A B C D T total_flow 18 path none bottleneck --- State No more paths: S → A S \to A S → A (10/10) and S → B S \to B S → B (8/8) both saturated. BFS from S S S finds nothing. Algorithm terminates.
Step 15 / 15 Arrowhead (forward) Arrowhead (reverse) Edge from node S to node A 10/10 Edge from node S to node B 8/8 Edge from node A to node B 2/5 Edge from node A to node C 6/7 Edge from node B to node D 10/10 Edge from node C to node D 1/3 Edge from node C to node T 7/9 Edge from node D to node T 11/12 S A B C D T min-cut: S side total_flow 18 path done bottleneck done State Result: Max flow = 18 = 18 = 18 . Min-cut: { S } \{S\} { S } vs { A , B , C , D , T } \{A,B,C,D,T\} { A , B , C , D , T } , capacity 10 + 8 = 18 10+8 = 18 10 + 8 = 18 .