Recitation_Flows
Recitation_Flows
Michael Levet
1 Learning Objectives
The primary goal of recitation this week is to become familiar with key terminology and constructions related
to network flows. In particular, we have the following learning outcomes.
Students will correctly identify the amount of flow that can be pushed in both the forward and backward
directions of edges.
Students will correctly identify flow-augmenting paths, including the amount of flow that can be pushed
along such paths.
Students will correctly identify paths that are not flow-augmenting and provide correct justification as
to why the paths are not flow-augmenting.
Students will use maximum flow procedures to determine maximum-size bipartite matchings.
2 Network Flows
3/4
B D
0/10 2/10
2/9
C E
(Recommended) Problem 1. Consider the flow network N . How much flow can be pushed in the forward
direction along the edge (B, D)? That is, how much flow can be pushed from B → D?
Example 1. While we can push flow forward across an edge, we can also push flow backwards. The intuition
is that we re-route flow along a flow-augmenting path. However, only existing flow can be re-routed.
(a) Consider the edge (D, C) in the flow network N above, which has a capacity of 6 units of flow and
currently has 1 unit of flow being routed through it. So we can push 5 units of flow from D → C, or we
can push 1 unit of flow backwards from C → D.
(b) Consider the edge (E, D). As there is no flow being pushed from E → D, we cannot push any flow
backwards from D → E.
1
(Recommended) Problem 2. Consider the flow network N above.
(a) How much flow can be pushed in the backward direction along the edge (B, D)? That is, how much flow
can be pushed from D → B?
(b) How much flow can be pushed in the backward direction along the edge (B, C)? That is, how much flow
can be pushed from C → B?
The goal of the Network Flow problem is to maximize the amount flow that we can route from a source vertex
s to a destination (or sink ) vertex t. The approach is to find a path through which we can push positive flow
and then push as much flow as possible. Such paths are called flow-augmenting paths.
(Recommended) Problem 3. Consider the flow networks N above. Determine whether each path is a
flow-augmenting path. If the given path is flow-augmenting, then clearly indicate the maximum amount of
flow that can be pushed through the path. If the given path is not flow-augmenting, then clearly explain why
the path fails to be flow-augmenting.
For the purpose of this problem, do not update N after considering a flow-augmenting path. That is, you
should work part (b) without considering part (a), and so on. The point of this problem is solely to identify
flow-augmenting paths.
(a) s → B → D → t.
(b) s → C → B → D → t.
(c) s → C → E → t.
(d) s → C → E → D → t.
(e) s → C → D → t.
(Recommended) Problem 4. Find a flow augmenting path in N that was not listed in Problem 3 . Clearly
indicate the maximum amount of flow that can be pushed through this path.
Remark 1. Finding flow-augmenting paths can be challenging, particularly as we can push flow in both the
forward and backwards directions. To this end, we introduce the residual graph. Informally, the residual graph
replaces each directed edge in a flow network with at most weighted two edges. The weights on the edges
indicate how much flow can be pushed along a given direction. Should we not be able to push any flow along
an edge in the original flow network, then the corresponding directed edge is omitted in the residual graph.
We make this precise with the following definition.
Definition 1. Let N (V, E, cap, f ) be a flow network, where V is our vertex set, E is our edge set, cap : E → R≥0
identifies our edge capacities, and f : E → R≥0 identifies the amount of flow being pushed across each edge.
The residual graph R(V, E, w) is a directed, weighted graph with the same vertex set as N . For each directed
edge (u, v) ∈ E, we include at most two directed edges in R, as follows:
If cap((u, v)) − f ((u, v)) > 0, we include the edge (u, v) in E(R) with weight w((u, v)) = cap((u, v)) −
f ((u, v)). That is, the edge (u, v) in R indicates that we can push cap((u, v)) − f ((u, v)) units of flow
from u → v.
If f ((u, v)) > 0, we include the edge (v, u) in E(R) with weight w((u, v)) = f ((u, v)). That is, the edge
(v, u) in R indicates that we can push f ((u, v)) units of flow in the backwards direction along the edge
(u, v) in N . That is, in N , we can push f ((u, v)) units of flow from v → u.
Note that if cannot push flow in a given direction, then we do not include a directed edge in the residual graph
R.
Example 2. Recall the flow graph N at the top of Page 1. We construct the residual graph R corresponding
to N , which is pictured below.
2
In N , we have the directed edge (B, D) which has a capacity of 4 and 3 units of flow being pushed
through it.
– As we can push at most 1 more unit of flow in the B → D direction, we include the directed edge
(B, D) in the residual graph R, with the weight of (B, D) as 1.
– As we have 3 units of flow being pushed from B → D, we can push at most 3 units of flow in the
D → B direction. So we also include the directed edge (D, B) in the residual graph R. The weight
of the (D, B) edge in R is 3, indicating we can push 3 units of flow from D → B in the original flow
network N .
In N , we hvae the directed edge (s, C), which has a capacity of 10 an no flow being pushed through it.
For this reason, we only include the directed edge (s, C) with weight 10 in the residual graph R. As there
is no flow being pushed through the (s, C) edge, we do not include the edge (C, s) in R.
The rationale for including the remaining edges in the residual graph R is similar.
1
B D
3 8
10
2
1
s 2 3 t
5
10 2
7
C E
2
(Recommended) Problem 5. Draw the residual graph corresponding to the flow network N pictured below.
9/9
5/5
B D
1/6 4/7
s 6/6 t
3/3 2/7
4/8
C E
6/6
3
3.1 Preliminaries- Bipartite Matchings
We begin with the definition of a matching.
Definition 2. Let G(V, E) be a simple, undirected graph. A matching M is a subset of E(G) such that if
{i, j}, {u, v} ∈ M are distinct edges, then {i, j} ∩ {u, v} = ∅. That is, no two distinct edges in M touch or
share any endpoints.
Remark 2. The above definition of a matching makes sense, even if the graph is not bipartite. We illustrate
with the next example.
3 2
Let M1 = {12}. As M1 only has one edge, no two distinct edges in M1 share a common endpoint. So
M1 is a matching. By similar argument, M2 = {23} and M3 = {13} are also matchings.
Let M4 = ∅. As M4 does not contain any edges, it vacuously satisfies the definition of a matching.
It is natural to ask whether we can add any edges to a matching. To this end, we again consider M1 = {12}.
Observe that as 23 shares the endpoint 2 with 12, the set {12, 23} is not a matching. By similar argument,
{12, 13} and {13, 23} are also not matchings. Clearly, {12, 23, 13} is also not a matching. So the four matchings
listed above are the only matchings of C3 .
1 2
4 3
Do the following.
Remark 3. It is of particular interest in algorithm design (as well as in graph theory, and application areas
such as algorithmic economics) to find a matching in the graph G with largest cardinality. We call such
matchings maximum, and the size of such a matching is called the matching number of G. We denote the
matching number of G as ν(G).
(a) G = C3 .
4
(c) G = C4 .
(e) G = K2,3 . [Refer back to Page 3, Example 6 of my Graph Theory notes on Canvas for the definition of
the Complete Bipartite Graph.]
(f) G = Km,n .
– V (N ) = V (G) ∪ {s, t}. That is, N has precisely the same vertices as G, and then we add a source
vertex s and a sink vertex t.
– For each edge {i, j} ∈ E(G) where i ∈ L and j ∈ R, we add a directed edge (i, j) with capacity 1 in
N.
– For each u ∈ L, we add a directed edge (s, u) with capacity 1 in N .
– For each v ∈ R, we add a directed edge (v, t) with capacity 1 in N .
We construct the matching M ⊂ E(G) corresponding to f ∗ by including the edges {i, j} ∈ E(G) if and
only if f ∗ ((i, j)) = 1. That is, the saturated edges from L → R in N are precisely the edges in the
corresponding maximum matching of G.
Example 4. We now work through an example of this construction. Let G be the graph pictured below.
y1
x1 y2
x2 y3
y1
0/1
x2 y3
5
Step 2: We now find a maximum flow. We stress that the selection of our flow-augmenting
paths below is a choice. There are other valid choices; that is, our selection is in a sense
arbitrary.
y1
0/1
x2 y3
y1
0/1
x2 y3
Step 3: We now construct the matching on G based on our maximum flow on N . Since the edges (x1 , y2 )
and (x1 , y2 ) are saturated on N , our corresponding maximum matching M = {{x1 , y2 }, {x2 , y1 }}.
Remark 4. We note that other maximum flows on N would yield different maximum matchings. We leave it
as an exercise for the reader to find the other maximum matchings of G.
(Recommended) Problem 8. Let G = K3,4 . The goal of this problem is to use the network flow reduction
to find a maximum matching of G.
(b) Find a maximum flow on N . Clearly identify each flow-augmenting path and the amount of flow you can
push through said path.
(c) Use the maximum flow from part (b) to determine the corresponding maximum matching on G.