Let (G,s,t,{c}) be a flow network, and let F be the set of all edges e for which there exists at least one minimum cut (A,B) such that e goes from A to B. Give a polynomial time algorithm that finds all edges in F.
NOTE: So far I know I need to run Ford-Fulkerson so each edges has a flow. Furthermore I know for all edges in F, the flow f(e) = c(e). However not all edges in a graph G which respects that constraint will be in a min-cut. I am stuck here.
Suppose you have computed a max flow on a graph
G
and you know the flow through every edge in the graph. From the source vertexs
, perform a Breadth First Search OR Depth First Search on the original graph and only traverse those edges that have flow less than the capacity of the edge. Denote the set of vertices reachable in this traversal asS
, and unreachable vertices asT
.To obtain the minimum cut
C
, we simply find all edges in the original graphG
which begin at some vertex inS
and end at some vertex inT
.This tutorial in Topcoder provides an explanation / proof of the above algorithm. Look at the section beginning with the following text:
I shall attempt to provide an explanation of the corresponding section in the Topcoder tutorial (just for me to brush up on this as well).
Now, suppose that we have computed a max flow on a graph
G
, and that we have computed the set of edgesC
using the procedure outlined above. From here, we can conclude several facts.Fact 1: Source vertex
s
must be in setS
, and sink vertext
must be in setT
.Otherwise, vertices
s
andt
must be in the same set, which means that we must have found a path froms
tot
consisting only of edges that have flow less than capacity. This means that we can push more flow froms
tot
, and therefore we have found an augmenting path! However, this is a contradiction, since we have already computed a max flow on the graph. Hence, it is impossible for source vertexs
and sink vertext
to be connected, and they must be in different sets.Fact 2: Every edge beginning at set
S
and ending at setT
must have flow == capacityAgain we prove this by contradiction. Suppose that there is a vertex
u
inS
and a vertexv
inT
, such that edge(u,v)
in the residual network has flow less than capacity. By our algorithm above, this edge will be traversed, and vertexv
should be in setS
. This is a contradiction. Therefore, such an edge must have flow == capacity.Fact 3: Removing the edges in
C
from graphG
will mean that there is no path from any vertex in setS
to any vertex in setT
Suppose that this is not the case, and there is some edge
(u,v)
that connects vertexu
in setS
to vertexv
in setT
. We can separate this into 2 cases:(u,v)
is less than its capacity. But we know this will cause vertexv
to be part of setS
, so this case is impossible.(u,v)
is equal to its capacity. This is impossible since edge(u,v)
will be considered as part of the edge setC
.Hence both cases are impossible, and we see that removing the edges in
C
from the original graphG
will indeed result in a situation where there is no path fromS
toT
.Fact 4: Every edge in the original graph
G
that begins at vertex setT
but ends at vertex setS
must have a flow of0
The explanation on the Topcoder tutorial may not be obvious on first reading and the following is an educated guess on my part and may be incorrect.
Suppose that there exists some edge
(x,y)
(wherex
belongs to vertex setT
andy
belongs to vertex setS
), such that the flow through(x,y)
is greater than 0. For convenience, we denote the flow through(x,y)
asf
. This means that on the residual network, there must exist a backward edge(y,x)
with capacityf
and flow0
. Since vertexy
is part of setS
, the backward edge(y,x)
has flow0
with capacityf > 0
, our algorithm will traverse the edge(y,x)
and place vertexx
as part of vertex setS
. However, we know that vertexx
is part of vertex setT
, and hence this is a contradiction. As such, all edges fromT
toS
must have a flow of 0.With these 4 facts, along with the Max-flow min-cut theorem, we can conclude that:
The max flow must be less than or equal to the capacity of any cut. By Fact 3,
C
is a cut of the graph, so the max flow must be less than or equal to the capacity of cutC
.Fact 4 allows us to conclude that there is no "back flow" from
T
toS
. This along with Fact 2 means that the flow consists entirely of "forward flow" fromS
toT
. In particular, all the forward flow must result from the cutC
. This flow value happens to be the max flow. As such, by the Max-flow min-cut theorem, we know thatC
must be a minimum cut.