Section 3.3 Network Flows
Definition 3.3.1.
A set of object, called vertices, and a set of ordered pairs of vertices, called edges is a digraph (directed graph) if and only if the set of vertices is finite, and no edge exists from a vertex to itself.
Example 3.3.2.
The following are digraphs.
\(V=\{v_1,v_2,v_3,v_4\}\) \(E=\{(1,2),(1,4),(2,1),(2,3),(3,4),(4,2)\}\)
\(\left[ \begin{array}{rrrr} 0 \amp 1 \amp 0 \amp 1 \\ 1 \amp 0 \amp 1 \amp 0 \\ 0 \amp 0 \amp 0 \amp 1 \\ 0 \amp 1 \amp 0 \amp 0 \end{array} \right]\)
\(V=\{v_1,v_2,v_3,v_4\}\) \(E=\{(1,2),(1,4),(2,3)\}\)
Problem 3.3.3.
Write the matrix for the digraph drawn above. Draw the digraph for the matrix and set shown above.
The matrix of the digraph shown is
The given matrix and the first set description correspond to the digraph shown.
Finally, the digraph for the second set description is
Definition 3.3.4.
A path is a directed path if and only if all edges are in the same direction.
Definition 3.3.5.
A graph is a directed cycle if and only if the vertices can be labeled \(v_1,v_2,v_3,\ldots,v_n\) such that the only edges are \((v_1,v_2), (v_2,v_3), (v_3,v_4),\ldots,(v_{n-1},v_n), (v_n,v_1)\) and only \(v_1\) is reused.
Definition 3.3.6. In degree.
In\((v)\) denotes the set of edges into vertex \(v\text{.}\) \(|\text{In} (v)|\) is the in-degree.
Definition 3.3.7. Out degree.
Out\((v)\) denotes the set of edges into vertex \(v\text{.}\) \(|\text{Out} (v)|\) is the out-degree.
Problem 3.3.8.
In the digraph pictured in Example 3.3.2 find a directed path from \(a\) to \(c\text{.}\) Find a path from \(a\) to \(c\) that is not a directed path.
Problem 3.3.9.
In the digraph pictured in Example 3.3.2 find a directed cycle. Find a cycle that is not a directed cycle. Find a directed cycle that is not a cycle.
A directed cycle can be found by following the edges \((A,B),(B,C),(C,D),(D,A)\text{.}\)
A cycle that is not a directed cycle requires us to follow at least one edge opposite to its direction. Such a cycle can be found by following the edges \((A,B),(B,D),(D,A)\) since it traverses edge \((B,D)\) opposite to its given direction.
A directed cycle that is not a cycle can be found by following edges \((A,B),(B,A)\text{.}\) This would not be a cycle in an undirected graph, since such a graph does not allow for two vertices sharing more than one edge Figure 1.2.2.
Problem 3.3.10.
In the digraph in Figure 3.3.12 find multiple, directed paths from \(a\) to \(z\text{.}\)
The following paths are directed paths from \(a\) to \(z\text{.}\)
A useful method of forming these paths is by first making choices from the starting edge, then keep making choices for the next pair of vertices until you reach a forced choice. For example, from (a, b) you have three choices for continuing a path, choose one such choice and continue along until the end vertex. You'd then have to return to (a, b) and choose from that remaining two possible paths. Repeat this process until you have covered every possibility.
\(\displaystyle P_1{(a, b), (b, d), (d, z)}\)
\(\displaystyle P_2{(a, b), (b. e), (e, g), (g, z)}\)
\(\displaystyle P_3{(a, b), (b, d), (d, c), (c, f), (f, g), (g, z)}\)
\(\displaystyle P_4{(a, b), (b, d), (d, c), (c, f), (f, e), (e, g), (g, z)}\)
\(\displaystyle P_5{(a, c), (c, f), (f, g), (g, z)}\)
\(\displaystyle P_6{(a, c), (c, f), (f, e), (e, g), (g, z)}\)
\(\displaystyle P_7{(a, f), (f, g), (g, z)}\)
\(\displaystyle P_8{(a, f), (f, e), (e, g), (g, z)}\)
Problem 3.3.11.
In the digraph in Figure 3.3.12 find a set of edges such that removing them disconnects every directed path from \(a\) to \(z\text{.}\)
We can find two distinct paths that connect point a to point z. (Paths {ab, bd,dz} and path {ac, cf, fg, gz}. So, we're going to need to remove at least two edges. If we remove edges dz and gz from the graph, we have removed all edges connected z to the graph. Therefore, removing the set of edges {dz, gz} will disconnect all paths, and, furthermore, this is the smallest set of edges whose removal will facilitate the disconnection.
Definition 3.3.13.
A digraph with weighted edges is a network.
Definition 3.3.14.
An integer valued function \(f\) is an \(a-z\) flow on a network if and only if
\(f\) is a function from the edges to the integers,
\(0 \le f(e) \le k(e)\) for every edge \(e\) where \(k(e)\) is the weight (capacity) of edge \(e\text{,}\)
For vertex \(x \ne a,z\) \(\displaystyle \sum_{e \in \mbox{In} (x)} f(e) = \sum_{e \in \mbox{Out} (x)} f(e)\text{,}\) and
There exists a source vertex \(a\) and a sink vertex \(z\text{,}\)
\(f(e)=0\) if \(e \in \mbox{In} (a)\) or \(e \in \mbox{Out} (z)\text{.}\)
Problem 3.3.15.
Determine which of the networks in Figure 3.3.16 have \(a-z\) flows on them. Note the left (blue) numbers are the capacities \(k(e)\) and the right (green) numbers are the alleged flow function \(f(e)\text{.}\)
Graph 4 has a a-z flow.
Before we study properties of \(a-z\) flows, we will practice creating them.
Problem 3.3.17.
A manufacturing company can ship its product via combinations of ground, air, and water. Figure 3.3.18 shows the amount of pounds of freight that can travel over each segment. Paths from c to z are by road; paths from h to z are by air; paths from j to z are by water. Determine the maximum poundage the company can ship by constructing an \(a-z\) flow on the network that has maximum total flow.
The maximum total flow \(F_{\text{max}}\) must be less than or equal to 130, since that is the sum of all of the edges into \(z\text{.}\) This is achievable with the flow assignments given in the table below.
Edge | Flow |
ac | 40 |
cd | 30 |
ce | 20 |
df | 20 |
eg | 20 |
ah | 40 |
hi | 40 |
iz | 30 |
im | 10 |
aj | 50 |
jk | 50 |
km | 20 |
kn | 30 |
mz | 30 |
nz | 30 |
Problem 3.3.19.
A company needs to assign six employees (b,c,d,e,f,g) to six projects (m,n,p,q,r,s) considering each employee's expertise. Figure 3.3.18 shows which employees have the necessary expertise for each project. Build an \(a-z\) flow to find a solution.
We can begin by recognizing that this problem is esstentially the same task as the toys problem from the very beginning of the course Table 1.1.6 but now has some formalism attached to it.
Each employee can be tasked to a single project for which they have the appropirate skill by making the following assignments:
Assign employee \(b\) to project \(m\text{.}\)
Assign employee \(c\) to project \(r\text{.}\)
Assign employee \(d\) to project \(n\text{.}\)
Assign employee \(e\) to project \(p\text{.}\)
Assign employee \(f\) to project \(q\text{.}\)
Assign employee \(g\) to project \(s\text{.}\)
Definition 3.3.22.
A set of edges is a cut set, denoted \((P,\overline{P})\text{,}\) if and only if the edges are generated by some set of vertices \(P\) such that for each edge \((x,y)\text{,}\) \(x \in P\) and \(y \in \overline{P}\text{,}\) where \(\overline{P}\) is the set complement of \(\overline{P}\text{.}\)
Definition 3.3.23.
A cut set is an \(a-z\) cut set if and only if \(a \in P\) and \(z \in \overline{P}\text{.}\)
Problem 3.3.24.
Select any set of vertices in the network in Figure 3.3.29. List the edges of the cut set generated by this set of vertices.
P = {a,b,c,d}, \(\overline{\rm P}\)= {e,f,g,z} Cut Set = {(d,z),(b,e),(a,f),(c,f)}
Problem 3.3.25.
Find four, distinct cut sets in the network in Figure 3.3.29. List the generating set \(P\) for each cut set. Which are \(a-z\) cut sets?
Problem 3.3.26.
Select an \(a-z\) cut set. Find any directed path from \(a-z\text{.}\) Does it use an edge of the cut set? Explain the name “cut set.”
Let P be the set of vertices {a,b,c,d,e,f,g}. So, (P,P')={dz,gz} is our a-z cut set.
Consider any path that connects a to z. As shown earlier in Problem 3.3.11, removing those two sets will disconnect any path from a to z. Indeed, any cut set will end up disconnecting the vertices P from P' as it removes all edges allowing us to escape P (although it may not nesscarily disconnect P' from P, due to the graph's directed nature). Therefore, any a-z cut set (where a is in P) will disconnect a-z paths.
Lemma 3.3.27.
For any vertex subset \(P\) not containing \(a\) or \(z\) of a network with \(a-z\) flow \(f\) the sum of the flow into \(P\) equals the sum of the flow out of \(P\text{.}\)
Proof.
Direct proof: Let P be a vertex subset of a network with a – z flow f, and P does not contain a or z.
By definition of a – z flow, for any vertex that does not equal a or z, the sum of the flow function f(e) into the vertex equals the sum of the flow out of the vertex.
Let's first add up the total flow into all vertices in P by simple addition. Then, we similarly add up the total flow out of all vertices in P.
These two sums are equal because the sum of the flow in and out of a vertex is equal (since a and z are not included).
Now we will simplify the equation by subtracting both sides by flows that appear on both sides of the equation. Note that we are subtracting all values except those that belong to flow into P and flow out of P.
Both sides of the equation are still equal, thus the sum of the flow into P equals the sum of the flow out of P.
Corollary 3.3.28.
For any \(a-z\) flow in a network, the flow out of \(a\) equals the flow into \(z\text{.}\)
Proof.
This follows directly from the proof above if we let
for then all of the flow out of \(a\) either flows into \(P\) or directly to \(z\text{.}\) The flow into \(P\) must leave \(P\) and flow directly to \(z\) so the flow out of \(a\) equals the flow into \(a\text{.}\)
Note \(|f|=\sum_{e \in \mbox{Out} (a)} f(e)\text{.}\) Also \(\displaystyle k(P,\overline{P})=\sum_{e \in (P,\overline{P})} k(e)\)
Problem 3.3.30.
Find all \(a-z\) cut sets in Figure 3.3.29. Of these sets of edges which has the least capacity?
Lemma 3.3.31.
Given a network with an \(a-z\) flow. The flow out of any set of vertices \(M\) containing the source is:
Proof.
Let \(N\) be a network with an \(a-z\) flow. Let \(P\) be be a set of vertices that contains any collection of vertices in \(N\) but not \(a\) or \(z\text{.}\) By Lemma 3.3.27, we know that
Now define a new set of vertices \(M=P\cup\{a\}\text{.}\) Consider every edge going out from \(a\text{:}\)
Was an edge that went from \(a\) to some element of \(\bar{P}\) which we can call \(\bar{P_i}\) and thus is now part of the count for \(\displaystyle \sum_{e \in (M,\bar{M})} f(e)\)
Was an edge from \(a\) to some element of \(P\) which we can call \(P_j\) and thus now needs to be subtracted from the count for \(\sum_{e \in (\bar{P},P)} f(e)\) when calculating \(\sum_{e \in (\bar{M},M)} f(e)\)
so we can write the sum of the flows out of \(M\) as:
and we can write the sum of the flows into \(M\) as:
But by Lemma 3.3.27, we know that:
But that means a slight algebraic rearrangement gives us:
But the two sums at the end account for every edge out of \(a\) so we arrive out our desired result
Lemma 3.3.32.
Conjecture and prove a relationship between \(k(P,\overline{P})\) and \(|f|\) for any network flow \(f\) and \(a-z\) cut set \((P,\overline{P})\text{.}\)
Proof.
We shall prove this by contradiction. Let \(N\) be a directed network with an \(a-z\) flow and \((P,\bar{P})\) be an \(a-z\) cut set on \(N\text{.}\)
Suppose \(|f|>k(P,\bar{P})\text{.}\) Since \((P,\bar{P})\) is an \(a-z\) cut set, \(P\) is a set of vertices that contains the source. A previous lemma Lemma 3.3.31 then gives us:
Since \(\displaystyle \sum_{e \in (\bar{P},P)} f(e) \geq 0\text{,}\) our assumption implies that \(\displaystyle \sum_{e \in (P,\bar{P})} f(e) > k(P,\bar{P})\text{.}\) A contradiction since the flow across the cut set cannot be greater than its capacity.
Thus, \(|f| \leq k(P,\bar{P})\)
Corollary 3.3.33.
For any \(a-z\) flow \(f\) and any \(a-z\) cut \((P,\overline{P})\text{,}\) \(|f|=k(P,\overline{P})\) if and only if
For each edge \(e \in (\overline{P},P)\text{,}\) \(f(e)=0\)
For each edge \(e \in (P,\overline{P})\text{,}\) \(f(e)=k(e)\)
Algorithm 3.3.34. Greedy Network Flow.
Build a maximal flow by building the following flow paths.
-
Generate a flow path as follows.
Let \(p=a\text{.}\) Let \(r=0\text{.}\)
Add the edge \((p,q)\) with the most remaining flow.
If this is the first edge, let \(r\) be the maximum available flow. For other steps let \(r\) be the minimum of itself and the maximum available flow of the current edge.
If \(q=z\) add this to the flow, add \(r\) to the flow on each edge, and return to Item 1.a,
otherwise let \(p=q\) and return to Item 1.b.
If there is no edge \((p,q)\) with flow greater than zero, return to Item 1.a.
Repeat until no new flow paths can be built.
Problem 3.3.35.
Construct a flow for the network in Figure 3.3.29 using the Greedy algorithm above. Does this flow reach the maximum flow?
Inital:\(p=a\text{,}\)\(r=0\)
1.\(p=a\text{,}\)add\((a,f)\text{,}\)\(r=8\)
2.\(p=f\text{,}\)add\((f,g)\text{,}\)\(r=5\)
3.\(p=g\text{,}\)add\((g,z)\text{,}\)\(r=5\)
\((a,f),(f,g),(g,z)=5\)
4.\(p=a\text{,}\)add\((a,b)\text{,}\)\(r=7\)
5.\(p=b\text{,}\)add\((b,e)\text{,}\)\(r=7\)
6.\(p=e\text{,}\)add\((e,g)\text{,}\)\(r=6\)
7.\(p=g\text{,}\)add\((g,z)\text{,}\)\(r=6\)
\((a,b),(b,e),(e,g)=6,(g,z)=11\)
8.\(p=a\text{,}\)add\((a,c)\text{,}\)\(r=6\)
9.\(p=c\text{,}\)add\((c,f)\text{,}\)\(r=6\)
10.\(p=f\text{,}\)add\((f,e)\text{,}\)\(r=4\)
No edge with flow greater than 0.
11.\(p=a\text{,}\)add\((a,f)\text{,}\)\(r=3\)
12.\(p=f\text{,}\)add\((f,e)\text{,}\)\(r=3\)
No edge with flow greater than 0.
13.\(p=a\text{,}\)add\((a,b)\text{,}\)\(r=1\)
14.\(p=b\text{,}\)add\((b,d)\text{,}\)\(r=1\)
15.\(p=d\text{,}\)add\((d,z)\text{,}\)\(r=1\)
\((a,b)=7,(b,d),(d,z)=1\)
Finish
Problem 3.3.36.
Find a flow for the network in Figure 3.3.29. Does it reach the maximum flow?
Problem 3.3.37.
Does the flow in Figure 3.3.38 reach the maximum flow? Can any flow be added?
Problem 3.3.39.
Use the graph in Figure 3.3.40 that shows the flow and replaces the capacity with the slack of the flow in Figure 3.3.38 to find a maximum \(a-z\) path. Ignore direction.
From vertex a, choose edge (a, f) because of the three edges from a, this has the most slack.
From vertex f, choose edge (f, e) because it has more slack than edge (f, g).
Continue in this manner to form path (a, f), (f, e), (e, b), (b, d), (d, z).
Notice that edge (e, b) is pointing in the "wrong" direction, but the slack of that edge is the greatest of the edges incident with e.
Problem 3.3.41.
How could this path be used to improve the flow?
The maximum a-z path on the graph representing the slack on the flow of Figure 3.3.38 is the path from a-z using the least amount of flow capacity for all path's from a to z. This path is {(a,f),(f,e),(e,b),(b,d),(d,z)}. To improve the flow we must find the edge with the least remaining capacity. In this case that edge is (f,e) with a remaining capacity of 4. We choose this edge because 4 must be the most amount of flow we can add to this path without making an edge have a remaining capacity below 0 and thus over capacity of that edge.
By subtracting 4 from the edges in the path that the path follows in that edge's direction, we improve the flow as seen in the image below. By adding 4 to the edge in the path that the path does not follow in that edges direction, we are able to make the flow of the graph possible without violating the rules of an a-z flow. The image below illustrates this method in action. The result is a flow with 4 greater than the previous flow.
Problem 3.3.42.
Repeat finding paths in the slack graph until the flow is maximum.
This image shows the result of applying the technique above.
Theorem 3.3.43.
We would like to prove that the following algorithm always produces the maximum flow. Recall that \(k(e)\) is the capacity of an edge, and \(f(e)\) is the flow assigned to an edge. \(s(e)\) is the slack on an edge \((k(e)-f(e))\)
Label \(a\) with \((-,\infty)\)
-
Choose a labeled vertex \(p\)
For each edge\(e=(q,p)\) with \(q\) unlabeled and \(f(e)>0\text{,}\) label \(q\) with \((p^{-},\Delta(q))\) with \(\Delta(q)=min(\Delta(p),f(e)\)
For each edge\(e=(p,q)\) with \(q\) unlabeled and \(s(e)>0\text{,}\) label \(q\) with \((p^{-},\Delta(q))\) with \(\Delta(q)=min(\Delta(p),s(e)\)
If \(z\) is labeled, continue to Item 4, otherwise return to Item 2 .
Find a \(z-a\) chain of slack edges using the shortest path algorithm.
Augment the flow on the edges of this path by adding the slack in the positive direction (labeled \(p^{+}\)) and subtracting it in the reverse direction (labeled \(p^{-}\)).
If there are no more slack chains, stop. Else return to Item 1.
Proof.
We will prove this by directly by making some observations about the state of the network at termination of the algorithm and invoking a useful lemma. Suppose we allow this algorithm to run to completion. The algorithm terminates when it is unable to label a set of vertices such that a path from \(a\) to \(z\) can be found using only labeled vertices. We can see then, that upon termination, there is a set of vertices that the algorithm can label (call that set \(P\)) and a set that the algorithm cannot label (call that set \(\bar{P}\)). It is obvious that \(P\) contains \(a\) and that \(\bar{P}\) contains \(z\text{.}\)
Since the algorithm cannot label any vertex in \(\bar{P}\text{,}\) but can still label all of the vertices of \(P\text{,}\) this implies that the slack in any forward edge connecting an element of \(P\) to an element of \(\bar{P}\) must be zero; i.e. the flow in the edge is equal to the capacity. It also becomes apparent that since the collection of edges running from elements of \(P\) to elements of \(\bar{P}\) form the only forward connections between a set containing \(a\) and a set containing \(z\) that this collection of edges must form an a-z cut set.
Similarly, since the algorithm cannot label any vertex in \(\bar{P}\text{,}\) but can still label all of the vertices of \(P\text{,}\) this implies that the flow in any backwards edge connecting an element of \(\bar{P}\) to an element of \(P\) must have flow equal to zero.
Invoking Lemma 3.3.31 we can see that:
But \(\displaystyle \sum_{e \in (\bar{P},P)} f(e)=0\text{.}\) Thus:
But we also know that every edge in \((P,\bar{P})\) has a flow equal to its capacity. This means that the set of edges \((P,\bar{P})\) must be the lightest possible cut set for the network and that the flow generated by the source has saturated this cut set. Thus we have achieved the conditions necessary for maximum flow and the algorithm will always produce a max flow, though that flow need not be unique.