![Page 1: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/1.jpg)
Algorithms, 4th Edition · Robert Sedgewick and Kevin Wayne · Copyright © 2002–2011 · February 23, 2012 4:05:54 PM
AlgorithmsF O U R T H E D I T I O N
R O B E R T S E D G E W I C K K E V I N W A Y N E
6.4 FORD-FULKERSON DEMO
click to begin demo
![Page 2: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/2.jpg)
2
‣ Ford-Fulkerson algorithm‣ computing a min cut
![Page 3: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/3.jpg)
Initialization. Start with 0 flow.
Ford-Fulkerson algorithm
3
s t
0 / 4
0 / 40 / 15
0 / 10 0 / 15
0 / 15
0 / 10
0 / 10
0 / 9
0 / 15
0 / 8
0 / 6
0 / 16
initialization
0 / 5 0
value of flow
0 / 10
flow capacity
![Page 4: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/4.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
4
0 / 4
0 / 40 / 15
0 / 15
0 / 15 0 / 10
0 / 9
0 / 8
0 / 6
0 / 16
s t
0 / 10 0 / 15
0 / 100 / 5
1st augmenting path
0
0 / 10
![Page 5: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/5.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
4
0 / 4
0 / 40 / 15
0 / 15
0 / 15 0 / 10
0 / 9
0 / 8
0 / 6
0 / 16
s t
0 / 10 0 / 15
0 / 10
0 / 10 0 / 15
0 / 100 / 5
1st augmenting path
0
0 / 10
![Page 6: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/6.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
4
0 / 4
0 / 40 / 15
0 / 15
0 / 15 0 / 10
0 / 9
0 / 8
0 / 6
0 / 16
s t
0 / 10 0 / 15
0 / 10
0 / 10 0 / 15
0 / 100 / 5
1st augmenting path
0
0 / 10
bottleneck capacity = 10
![Page 7: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/7.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
4
0 / 4
0 / 40 / 15
0 / 15
0 / 15 0 / 10
0 / 9
0 / 8
0 / 6
0 / 16
s t
0 / 10 0 / 15
0 / 10
0 / 10 0 / 15
0 / 10
10
10
10
—
—
—0 / 5
1st augmenting path
0 + 10 = 10
0 / 10
bottleneck capacity = 10
![Page 8: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/8.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
5
0 / 5
0 / 4
0 / 4
0 / 15
0 / 15
0 / 10
0 / 9
0 / 8
0 / 6
10 / 10 10 / 15
10 / 10s t
0 / 15 0 / 10
0 / 16
2nd augmenting path
10
![Page 9: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/9.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
5
0 / 5
0 / 4
0 / 4
0 / 15
0 / 15
0 / 10
0 / 9
0 / 8
0 / 6
10 / 10 10 / 15
10 / 10s t
0 / 15 0 / 10
0 / 16
0 / 15 0 / 10
0 / 16
2nd augmenting path
10
![Page 10: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/10.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
5
0 / 5
0 / 4
0 / 4
0 / 15
0 / 15
0 / 10
0 / 9
0 / 8
0 / 6
10 / 10 10 / 15
10 / 10s t
0 / 15 0 / 10
0 / 16
0 / 15 0 / 10
0 / 16
10
10
10
—
—
—
2nd augmenting path
10 + 10 = 20
![Page 11: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/11.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
6
0 / 4
0 / 4 0 / 150 / 6
10 / 10
10 / 10
10 / 15 10 / 10
10 / 16
s t0 / 5
0 / 10
0 / 9
0 / 8
10 / 15
3rd augmenting path
20
0 / 15
![Page 12: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/12.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
6
0 / 4
0 / 4 0 / 150 / 6
10 / 10
10 / 10
10 / 15 10 / 10
10 / 16
s t0 / 5
0 / 10
0 / 9
0 / 8
10 / 15
0 / 5
0 / 10
0 / 9
0 / 8
10 / 15
3rd augmenting path
20
0 / 15
backward edge
(not empty)
![Page 13: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/13.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
6
0 / 4
0 / 4 0 / 150 / 6
10 / 10
10 / 10
10 / 15 10 / 10
10 / 16
s t0 / 5
0 / 10
0 / 9
0 / 8
10 / 15
0 / 5
0 / 10
0 / 9
0 / 8
10 / 15
3rd augmenting path
20 + 5 = 255
—
5
—
5—
5—
5—
0 / 15
backward edge
(not empty)
![Page 14: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/14.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
7
0 / 4
0 / 4 0 / 15
10 / 10
10 / 105 / 5s t
0 / 6
5 / 10
5 / 9
5 / 8
5 / 15
10 / 1010 / 15
10 / 16
4th augmenting path
25
0 / 15
![Page 15: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/15.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
7
0 / 4
0 / 4 0 / 15
10 / 10
10 / 105 / 5s t
0 / 6
5 / 10
5 / 9
5 / 8
0 / 6
5 / 10
5 / 9
5 / 8
5 / 155 / 15
10 / 1010 / 15
10 / 15
10 / 1610 / 16
4th augmenting path
25
0 / 15
backward edge
(not empty)
![Page 16: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/16.jpg)
Augmenting path. Find an undirected path from s to t such that:
• Can increase flow on forward edges (not full).
• Can decrease flow on backward edge (not empty).
Idea: increase flow along augmenting paths
7
0 / 4
0 / 4 0 / 15
10 / 10
10 / 105 / 5s t
0 / 6
5 / 10
5 / 9
5 / 8
0 / 6
5 / 10
5 / 9
5 / 8
5 / 155 / 15
10 / 1010 / 15
10 / 15
10 / 1610 / 16
4th augmenting path
25 + 3 = 288
—
2—
8—
8—
13—
13
—
3—
0 / 15
backward edge
(not empty)
![Page 17: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/17.jpg)
Termination. All paths from s to t are blocked by either a
• Full forward edge.
• Empty backward edge.
Idea: increase flow along augmenting paths
8
no more augmenting paths
0 / 4
0 / 4 0 / 15
10 / 10
10 / 105 / 5s t
3 / 6
8 / 10
8 / 9
8 / 8
2 / 15
10 / 1013 / 15
28
13 / 16
0 / 15
full forward edge
empty backward edge
![Page 18: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/18.jpg)
9
‣ Ford-Fulkerson algorithm‣ computing a min cut
![Page 19: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/19.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
s
13 / 156 / 6
3 / 4
A
![Page 20: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/20.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 156 / 6
3 / 4
A
![Page 21: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/21.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
forward edge
(not full)
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 15
13 / 156 / 6
3 / 4
A
![Page 22: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/22.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
forward edge
(not full)
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 15
13 / 156 / 6
3 / 4
A
![Page 23: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/23.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
forward edge
(not full)
backward edge
(not empty)
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 15
13 / 156 / 6
3 / 43 / 4
A
![Page 24: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/24.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
forward edge
(not full)
backward edge
(not empty)
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 15
13 / 156 / 6
3 / 43 / 4
A
![Page 25: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/25.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
forward edge
(not full)
backward edge
(not empty)
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 15
13 / 156 / 66 / 6
3 / 43 / 4
A
![Page 26: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/26.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
forward edge
(not full)
backward edge
(not empty)
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 15
13 / 156 / 66 / 6
3 / 43 / 4
A
![Page 27: 6.4 FORD-FULKERSON DEMO - DePaul Universityfpl.cs.depaul.edu/jriely/ds1/extras/demos/64DemoFordFulkerson.pdf · Initialization. Start with 0 flow. Ford-Fulkerson algorithm 3 s t 0](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d89207e708231d43ad7cc/html5/thumbnails/27.jpg)
To compute mincut (A, B) from maxflow f :
• By augmenting path theorem, no augmenting paths with respect to f.
• Compute A = set of vertices connected to s by an undirected pathwith no full forward or empty backward edges.
Computing a mincut from a maxflow
10
forward edge
(not full)
backward edge
(not empty)
0 / 4
0 / 15
10 / 10
10 / 105 / 5 t
8 / 10
8 / 9
8 / 8
2 / 15
10 / 10
16 / 16
0 / 15
ss
13 / 15
13 / 156 / 66 / 6
3 / 43 / 4
full forward edge
empty backward edge
A