You are on page 1of 11

Algorithm Design Techniques

Assignment 1: Solutions

(1) Ford Fulkerson Algorithm.

4
2 3
a e t
3
2
5
5 4 3
s d c

2 3 2
4
b f

Initial digraph G

(a) For the shortest augmenting path implementation of the Ford Fulkerson
algorithm, we start with initial labels of all vertices. Recall that d(v) is
the length of the shortest path from v to t (in the pictures below, they are
in red color). So, in first iteration we find P1 = {s, a, t} as an admissible
path with residual capacity b(P1 ) = 3. Remember that, by definition of
admissibility, P1 must be the shortest path from s to t in this residual
graph network.
1
2

4
1 1 0
2 3
a e t
3
2
5
3
5 4 3
2 s d c 2

2 3 2

4
b f
2 1

Iteration 1: P1 = {s, a, t}, b(P1 ) = 3

Now we have d(s) = 2, d(d) = 3 and d(b) = 2, hence there is no


admissible edge going out from s, we must update d(s). Recall that
d(s) := min(s,v)∈Gf d(v) + 1 = min{d(b), d(d)} + 1 = 3. Now sb is an ad-
missible edge and the path P2 = {s, b, f, t} is admissible with b(P2 ) = 2.

1
1 1 0
2 3
a e t

32
3 5
3
5 4 3
3 s d c 2

2 3 2

4
b f
2 1

Iteration 2: d(s) = 3, P2 = {s, b, f, t}, b(P2 ) = 2

In the resulting graph, the only edge that goes out from s is sd but it
6 d(d) + 1, hence we update d(s) := 4.
is not admissible since d(s) = 3 =
3

Now the path P3 = {s, d, c, a, t} is admissible with the residual capacity


b(P3 ) = 1.

1
1 1 0
2 3
a e t

32
3 5
3
5 4
4 s d c 2 1
2
3 2
2
2
b f
2 2 1

Iteration 3: d(s)=4, P3 = {s, d, c, a, t}, b(P3 ) = 1

In the new residual graph, P4 = {s, d, b, f, t} is an admissible path with


b(P4 ) = 1.

4
1 1 0
2 3
a e t

1
2
43 3 4 3
4 s d c 2 1
1 1 2
3 2
2
2
b f
2 2 1

Iteration 4: P4 = {s, d, b, f, t}, b(P4 ) = 1

So after forth iteration, Gf looks like this.


4

4
1 1 0
2 3
a e t

1
2
3 4 3
3 3
4 s d c 2
2 1 3
1 2 2
2
1
b f
2 2 1

Gf after iteration 4

Now we try to construct a new admissible path. Note that sd, dc, ca
are admissible edges, however ae is not, hence we have to update the
label of a, d(a) := min{d(e), d(c)} + 1 = 2. But now ca is no longer an
admissible edge, hence we try to find another admissible edge going out
from c, but there is none, hence we update d(c) := 3. At this point dc is
not admissible anymore and we try to find an admissible edge going out
from d. There is one! It is db. Note that at this point our path is so far
{s, d, b}. Now we continue, there is an admissible edge going out from b
- bf . We add f to the path and continue. There is no admissible edge
going out from f , hence we have to update d(f ) := 3. Note that now bf
is not an admissible edge anymore, hence we remove bf from the current
path and try to find another admissible edge going out from b - there
is none. Hence we update d(b) := min{d(s), d(d), d(f )} + 1 = 4. After
this change, db is no longer an admissible path, hence we remove this
edge from the path and try to find an admissible edge going out from d.
Remember that at this point we have d(d) = 3, d(c) = 3, d(b) = 4, hence
we have to update d(d) := 4. This forces the update d(s) := 5. Now dc is
an admissible edge and so is ca (since earlier we updated d(a) = 2) and
we can complete the path by adding ae and et, both being admissible
edges. The final path is P5 = {s, d, c, a, e, t} with b(P5 ) = 2.
5

4
2 1 0
2 3
a e t

1
2
33 4 4 3
5 s d c 3
2 1 3
1 2 2
2
1
b f
4 2 3

Iteration 5: P5 = {s, d, c, a, e, t}, b(P5 ) = 2

And finally, in this new residual graph network, there is no s − t directed


path, hence the algorithm has to stop and its value is 3 + 4 + 2 = 9.

4
2 1 1 0
a e t

3 2
2
3 2 1
1 4
5 s d c 3
4 3 3
1 2 2
2
1
b f
4 2 3

Iteration 6: Gf , no s − t directed path


6

(b) In this problem we find the maximum flow using maximum residual ca-
pacity paths. In the first iteration, the augmenting path with the max-
imum residual capacity is P1 = {s, d, c, a, t}. This has residual capacity
b(P1 ) = 4.

2 3
a e t
3
2
5
5 4 3
s d c

2 3 2

4
b f

Iteration 1: P1 = {s, d, c, a, t}, b(P1 ) = 4

For the resulting residual graph the new shortest augmenting path is
P2 = {s, a, c, d, b, f, t} with residual capacity b(P2 ) = 3.

4
2 3
a e t
3 4
2
1 1 3
s d c
4
4
2 3 2

4
b f

Iteration 2: P2 = {s, a, c, d, b, f, t}, b(P2 ) = 3

Then for the resulting residual graph the new shortest augmenting path
is P3 = {s, b, d, c, a, e, t} with residual capacity b(P3 ) = 2.
7

2 4 3
a e t

1
3 2
1 4 3
s d c
3
4 3
2 3 2
1
b f

Iteration 3: P3 = {s, b, d, c, a, e, t}, b(P3 ) = 2

The next residual graph has no directed s − t path. So we have found the
maximum flow f ∗ and its value is 4 + 3 + 2 = 9.

4 1
a e t
2 2
3
3 2
1 2 1
s d c
3
4 5
1 2 2
2 1
b f

Iteration 4: Gf , no directed s − t path

(c) It the final iteration for b) when we try to grow directed paths from s we
can only reach a, b, c, d, f . Thus the reachable set is S ∗ = {s, a, b, c, d, f }.
The cut δ + (S ∗ ) contains the arcs (a, e), (a, t), (f, t) so has capacity 2 +
4 + 3 = 9. This is a minimum cut and it certifies the maximality of the
8

flow f ∗ we found in a).

(2) Mobile Networks. We can solve this problem by transforming it to a max-flow


problem as follows. We create a bipartite graph with vertices C ∪ B where
the vertices in C are the clients and the vertices in B are the base stations.
There is an arc from client c ∈ C to base station b ∈ B if they are distance at
most r apart. We add a source s and arcs (s, c) of capacity 1 for each c ∈ C;
we add a sink t arcs (b, t) of capacity L for each b ∈ B. It is easy to see that
there every client can be feasibly connected to a base station if and only if
the max-flow has value |C|. As the min-cut is at most |C| the Ford-Fulkerson
algorithm solves this problem in polynomial time.

(3) Malicious Attacks. Observe that for this question we are restricted to at
most O(k log n) pings; the actual run-time of the algorithm is not restricted
although, of course, we want it to be polynomial time.
Since the maximum flow f ∗ has value k and every arc has capacity 1,
this implies that f ∗ can be decomposed into exactly k arc-disjoint paths
P1 , P2 , . . . , Pk . We can find these paths in time O(mk) using the Ford-Fulkerson
algorithm.
Now the attacker has destroyed exactly k arcs. Thus, there is exactly one
arc destroyed on each of these paths (because no two paths share an arc,
and because the are no s-t paths left after removing these arcs). Each path
P1 , P2 , . . . , Pk has length O(n) so to find which arc on Pi was removed we
simply using a bisection-search ping algorithm on the path. That is, ping the
middles vertex on Pi . If that is found ping the vertex one quartre of the way
along Pi ; otherwise ping the vertex three-quarters of the way along Pi , etc. So
we use O(log n) paths per path as required to detect all the removed edges,
i.e. between the last vertex on the path that we can ping and the first vertex
we can’t ping must be the removed edge. Called the removed edges E ∗ . Since
we know what the graph looks like originally, we perform a BFS in O(m) on
G − E ∗ to find all the vertices that are reachable in the network. And return
those that aren’t.

(4) Ford Fulkerson Algorithm: Irrational Capacities.


We can view the arc (c, d) has having capacity 0. It is easy to see that the
minimum-cut is δ + (S ∗ ) occurs with S = {s, a, e, c}. So the arcs in the min-cut
are δ + (S ∗ ) = (c, d), (a, b), (e, f ). Initially, these arcs have residual capacities
{0, γ, γ 2 }.
9

Now suppose the Ford Fulkerson algorithm first augments along the path,
P1 = {(s, a), (a, b), (b, d), (d, c), (c, e), (e, f ), (f, t)}
The bottleneck value is γ 2 . After this augmentation the arc (a, b) has residual
capacity γ − γ 2 = γ 3 . To see this recall that we know γ + γ 2 = 1 and so we
have γ 2 + γ 3 = γ. So, the arc (a, b) has residual capacity γ 3 . The arc (c, d)
has residual capacity γ 2 as this amount was sent along its reverse (d, c); the
arc (e, f ) has residual capacity γ 2 − γ 2 = 0. The residual capacity of all the
other arcs are infinite as their capacities are infinite.
Hence now the arcs in the min-cut have residual capacities {γ 2 , 0, γ 3 }.

Suppose then Ford Fulkerson algorithm next augments along


P2 = {(s, c), (c, d), (d, f ), (f, e), (e, a), (a, b), (b, t)}
The bottleneck value is γ 3 . After this augmentation the arc (a, b) has residual
capacity 0. The arc (c, d) has residual capacity γ 2 − γ 3 = γ 4 . The arc (e, f )
10

has residual capacity γ 3 as this amount was sent along its reverse (f, e). The
residual capacity of all the other arcs are infinite as their capacities are infinite.
So the residual capacities of the arcs in min-cut are {0, γ 3 , γ 4 }.

Now, Suppose Ford Fulkerson algorithm augments along

P3 = {(s, e), (e, f ), (f, b), (b, a), (a, c), (c, d), (d, t)}

The bottleneck value is γ 4 . After this augmentation the arc (a, b) has residual
capacity γ 4 as this amount was sent along its reverse(b, a) The arc (c, d) has
residual capacity 0. The arc (e, f ) has residual capacity γ 3 − γ 4 = γ 5 . The
residual capacity of all the other arcs are infinite as their capacities are infinite.
So the residual capacities of the arcs in min-cut are {0, γ 4 , γ 5 }.

But now the residual graph looks exactly like our original graph, except
that the edges (a, b) and (e, f ) have their capacities multiplied by a constant
value γ 3 . So we can always use the same series of augmenting paths again and
again, and this will just change the capacities of (a, b) and (e, f ) by a constant
value γ 3 each time. So this pattern continues and we get the original situation
with capacities multiplied by γ 3 .
11

So that there may be an infinite number of iterations leading to a flow of


value
X X γ2 γ2
γ n+1 = γ 2 · γn = = 2 =1
n≥1 n≥0
1−γ γ
In this case this does lead to a maximum flow.
[Remark: With irrational capacities, it is actually possible to construct ex-
amples where the Ford-Fulkerson algorithm can select augmenting paths that
converge in total value to something less than the max-flow value!]

(5) Unique Min-Cut. Suppose there are at least two s − t min-cuts, say δ + (S1 )
and δ + (S2 ), where δ + (S1 ) is the cut we obtain from our max-flow/min-cut
algorithm.
Let δ + (S2 ) = {a1 , a2 , . . . , ak }. Then the must be some edge ai where ai is
in δ + (S1 ) but not in δ + (S2 ). Hence, if we increase the capacity of arc ai by
one then cap(S) increases by one but cap(S2 ) does not change. Thus, if we
now run the max-flow we will not find the cut δ + (S1 ) - we will find δ + (S2 ) (or
another min-cut). Thus we will know that there are at least two min-cuts in
the original graph.
But how do we find ai ? Easy, try all aj with 1 ≤ j ≤ k and pick the one
that works. If none work then δ + (S1 ) was a unique min-cut.

(6) Multiple Max-Flows. Let the minimum cut in G have capacity k. We need to
show that if (i, j) is not in any minimum cut then there is some maximum
flow f ∗ with fij∗ < uij . Now if if (i, j) is not in any minimum cut then every
cut it is in has capacity at least k + 1. So if we reduce the capacity of (i, j) by
one, that is u0ij = uij − 1, then the minimum cut in the new graph G0 is still
equal to k. But then G0 has a maximum flow f 0 of value k and fij0 ≤ u0ij < uij .
Now f 0 is clearly a maximum flow in the original graph G that does not use
all of the capacity of (i, j).

You might also like