Network Flows - Advanced Algorithms - Lecture Notes, Study notes of Advanced Algorithms

Main points of this lecture are: Network Flows, Matching Problems, Storage Capacity, Directed Graph, Capacity Constraint, Real Numbers, Skew Symmetry, Flow Conservation, Edge Capacities, Pair of Nodes, Total Inbound Flow, Constraint Force

Typology: Study notes

2012/2013

Uploaded on 04/23/2013

atasi
atasi 🇮🇳

4.6

(32)

134 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 2: Network Flows1
A wide variety of problems, including the matching problems discussed
in the previous lectures, can be described and analyzed in terms of Flow
Networks. In this lecture, we introduce the basic forms and laws governing
Flow Networks, and develop several theorems useful for their analysis.
1 Definitions
1.1 Flow Networks
A flow network G= (V, E) is a directed graph such that:
Gcontains a source node sand a sink node t
every vertex vVis on some path between sand t
every edge (u, v)Ehas a capacity c(u, v)0
nodes have no storage capacity
Figure 1 shows an example of a flow network.
1.2 Flows
A flow fin a network Gis a function that assigns real numbers to edges such
that following constraints are satisfied:
capacity constraint:(u, v)E, f (u, v)c(u, v)
1These lecture notes are adopted in part from a set of lecture nots scribed by Jared
Hunter and Daniel Vukelich in 2004.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Network Flows - Advanced Algorithms - Lecture Notes and more Study notes Advanced Algorithms in PDF only on Docsity!

Lecture 2: Network Flows^1

A wide variety of problems, including the matching problems discussed in the previous lectures, can be described and analyzed in terms of Flow Networks. In this lecture, we introduce the basic forms and laws governing Flow Networks, and develop several theorems useful for their analysis.

1 Definitions

1.1 Flow Networks

A flow network G = (V, E) is a directed graph such that:

  • G contains a source node s and a sink node t
  • every vertex v ∈ V is on some path between s and t
  • every edge (u, v) ∈ E has a capacity c(u, v) ≥ 0
  • nodes have no storage capacity

Figure 1 shows an example of a flow network.

1.2 Flows

A flow f in a network G is a function that assigns real numbers to edges such that following constraints are satisfied:

  • capacity constraint: ∀(u, v) ∈ E, f (u, v) ≤ c(u, v) (^1) These lecture notes are adopted in part from a set of lecture nots scribed by Jared Hunter and Daniel Vukelich in 2004.

Figure 1: A flow network G = (V, E) with edge capacities specified.

  • skew symmetry: ∀(u, v) ∈ E, f (u, v) = −f (v, u)
  • flow conservation: ∀u, v /∈ {s, t},

f (u, v) = 0

Since c(u, v) is defined for each pair of nodes for which ∃(u, v) ∈ E, we can think of the capacity constraint as merely stating that no flow between two directly connected nodes can possibly exceed the capacity of the edge that exists between them.

The skew symmetry constraint follows from the fact that flow net- works are directed graphs. Another definition would be ∀u, v ∈ V, f (v, u) = −f (u, v), for only flows directed contrary to the underlying path direction will ever be labeled with negative values.

The flow conservation constraint applies to all nodes except source s and sink t, because the output potential of a source and input potential of a sink are both ∞. For all other nodes, however, the total outbound flow must always equal the total inbound flow (nodes have no storage capacity), and semantics imposed by the skew symmetry constraint force the sum of all flows to zero.

The total flow between two sets of nodes is the sum of the flows from any member of the first set to a member of the second set. When the sets are identical, total net flow is zero by the flow conservation constraint. When the sets are not identical, the total net flows from each set to the other have equal absolute value and opposing sign. When the two sets are disjoint, the total net flow from their union to any third set Z ⊆ V is the sum of their individual net flows to that subset, and vice versa.

1.4 Residual Networks

Instead of viewing a flow network in terms of capacities in use, it can be useful to view it in terms of capacities remaining (unused capacities). This representation is called a residual network. Given a network G = (V, E) and a flow f in G, the residual network is Gf (V, Ef ) where:

  • Ef = {(u, v) where cf (u, v) > 0 }
  • cf (u, v) = c(u, v) − f (u, v)

So if there is no remaining capacity along an edge in the flow network, that edge should not appear in our chosen representation of Gf , an effect illus- trated in Figure 3.

We can also draw residual networks with a complete set of back edges, whose values maintain the residual network’s compliance with the flow con- servation constraint. For simplicity, these edges (call them Eb) are shown separately in Figure 4, these edges are called backward edges. The Gf is really defined by (V, Ef ∪ Eb).

It’s important to note that the values of the backward edges are not always simply the values of the forward flows in G. In cases where a network specifies forward edges (i, j) and (j, i) (as our network does between nodes A and C, for example), the values of the residual edges may be calculated. Given flows xij and xji, and unused capacities uij and uji respectively:

  • residual edge rij = (uij − xij ) + xji, for forward edges
  • residual edge rji = (uji − xji) + xij , for backward edges

Figure 3: The forward edges of residual network resulting from the flow in Figure 2.

Figure 4: The backward edges of residual network resulting from the flow in Figure 2.

The capacity of a cut (S, T ) is:

c(S, T ) =

u∈S,v∈T

c(u, v) (7)

Claim 1.5.1 While the capacities of different cuts may be different, the total value of flow across a cut boundary is always constant.

()*+#

()*,# *+),-#

.).# *).#

*)/#

-)*-#

-).# -)(# 0)0#

Figure 6: Three cuts of a flow network.

We will not prove the claim here, but will try to bolster its intuitiveness with an example. Figure 6 shows cuts of our familiar flow network. We will calculate the capacity and flow across each cut separately.

  • S 1 = {s}, T 1 = {A, B, C, D, t} c(S 1 , T 1 ) = c(s, A) + c(s, C) = 16 + 13 = 29 f (S 1 , T 1 ) = f (s, A) + f (s, C) = 9 + 11 = 20
  • S 2 = {s, A, B, C, D}, T 2 = {t} c(S 2 , T 2 ) = c(B, t) + c(D, t) = 20 + 4 = 24 f (S 2 , T 2 ) = f (B, t) + f (D, t) = 16 + 4 = 20
  • S 3 = {A, s, B, D}, T 3 = {C, t} c(S 3 , T 3 ) = c(A, C) + c(s, C) + c(B, C) + c(B, t) + c(D, t) c(S 3 , T 3 ) = 4 + 13 + 9 + 20 + 4 = 50 f (S 3 , T 3 ) = f (s, C)+f (B, t)+f (D, t)−f (C, D) = 11+16+4−11 = 20

2 The Max-Flow Problem

Given (G, s, t), the Max-Flow problem is that of finding a maximal-capacity flow in G from source s to sink t. We call the value of this maximal flow f ∗.

2.1 The Max-Flow Min-Cut Theorem

The Max-Flow Min-Cut theorem states that f ∗, the value of the maximum flow, is equal to the minimum cut capacity out of all possible cuts of G.

Theorem 2.1.1 (Maxflow/Mincut Theorem) Given a network, G, and a flow, f , the following are equivalent:

  1. f is a maximum flow in G
  2. the residual network Gf contains no augmenting paths
  3. we can find some cut (S, T ) for which |f | = c(S, T )

Proof.

  • 1 → 2. If Gf contained an augmenting path then we could improve f , in which case |f | would not be maximum and f would not be a maximum flow.
  • 2 → 3.
    1. assume Gf has no augmenting path
    2. let S = {v ∈ V such that v is reachable from s in Gf }
    3. let T = V − S
    4. notice s ∈ S, but t /∈ S. t is not reachable in Gf because there are no augmenting paths
    5. ∀u ∈ S, ∀v ∈ T : f (u, v) = c(u, v) (a) assume f (u, v) ≤ c(u, v) (maybe we can improve f (u, v))

12

13 4/

9 7

16/

12/

4/10 4

4/

12/

(c) 10

13

12

4

6 8 9 7

8

4

(d)

16 12

14

13 4

10 4 9 7

12/

12/ 12/

(a)

14

13

4

12

4

10 4 9 7

8

(b)

12

Figure 7: Flows in G and its residual network.

Claim 2.2.1 The Ford-Fulkerson algorithm always terminates and always returns a maximum flow.

2.2.1 Time Complexity of Ford-Fulkerson Algorithm

Initialization of f and the construction of Gf are both O(|E|), as is the process of finding an augmenting path. The while loop is executed at most |f ∗| times, since the augmenting path increases flow by at least one unit each iteration. It is therefore easily seen that worst case bounds are O(|f ∗||E|).

Now, consider the flow in Figure 8. In (a), a flow of 1 unit follows the path of dotted lines and, (b) shows the resulting residual network. Now, suppose the next augmenting path is that highlighted in (b); once again, an increase in flow of 1 unit will result, and this alternating pattern can continue |f ∗| times, exhibiting the worst case performance. For improved performance, we next sketch the Edmonds-Karp algorithm.

(b)

1/

1/1,000,000 1,000,

1,000,000 (^) 1/1,000,

(a)

1

1,000,000 (^) 999,

1

999,999 1,000,

1

Figure 8: Worst case flow in Ford-Fulkerson

2.3 The Edmonds-Karp Algortihm

Instead of choosing any augmenting path each time through the while loop, we might instead choose, among augmenting paths to choose, a path that optimizes some criteria. The Edmonds-Karp algorithm always chooses a path with the minimum number of comprising edges. It makes a new network from residual network where edge weights are replace by ’1’ and then employs a breadth-first search to choose the shortest augmenting path from s to t. That shortest augmenting path corresponds to an augmented path in the residual network with the f ewest number of edges. Referring to Figure 8, choosing path with the fewest number of edges(namely the paths of two edges of 1,000,000 along the top and bottom of the graph) would have readily achieved the 2,000,000 capacity maximum flow by avoiding the extra edge of capacity 1 (the bottleneck). Moreover, maximum flow would then have been realized in two iterations of the while loop instead of 2,000, by Ford-Fulkerson!

2.3.1 Time Complexity of Edmonds-Karp Algorithm

Lemma 2.3.1 If the E-K algorithm is run on a flow network with source s and sink t, then for all verticie v ∈ V − {s, t}, the shortest path distance can only increase in the residual network.

Let u, v be vertices in V connected by an edge in E. We claim that from the time (u, v) is critical to the next time it becomes critical again, its distance to s must increase by 2.

Let f be the flow when its f irst critical: df (s, v) = df (s, u) + 1 (since augmenting paths are shortest paths). Then (u, v) disappears from residual network can not appear again until (u, v) appears on an augmenting path. For some flow f ′:

df ′^ (s, u) = df ′^ (s, v) + 1 ≥ df ′ (s, u) + 1 = df (s, u) + 2 →←