Notes 10 Graphs
Notes 10 Graphs
Example:
v1 has one out flow of 10 going to v2 and at the same time v2 has outflow of 4 going to v1. So we
introduced a new node v’ accepting flow from v1 and giving outflow to v2. This way, we removed cycle
from the graph.
Flow of a network is sum all outgoing flows from the source s, or sum of all incoming flows in the sink.
Source and Sink
There will be no inward edges at source and outward edges from sink.
In min-cut we only count edges going out (means they are contributing to the path towards sink)
The capacity of minimum cut value, is going to be the maximum flow.
The given edge weights in a graph tells the capacity (of e.g., water) on the edge.
By default the capacities are given on the edges of the graph. As shown in first graph of below figure.
As first step we set the flow of graph equal to zero, e.g., an edge will capacity 13 will be written as 0/13
which is flow/capacity.
Then, we pick a random path, and find the edge e with minimum capacity Ce(p) on that path. This is
called bottleneck edge.
For example, in below figure, we pick the path as s -> v1 -> v3 -> t, highlighted as yellow.
We add the Ce(p) to the flows of edges on the same path, mark the edge as blocked where we have
flow==capacity, e.g., v1 to v3 in the below graph, we have now 12/12 and marked as blocked.
Example:
In picking the next path, if we already have a none zero flow on edge, then we will subtract the flow from
capacity, and find the edge whose flow after subtraction is minimum to identify the bottleneck edge.
The process is repeated until all the paths are blocked (i.e., when an edge of the path has label a/b on a
path where a==b, and we marked that edge as reverse edge)
Whatever total flow leaves the source should be equal to the one entering the sink in max flow.
Min-Cut
We want to perform a cut on edges in original graph so that the edges through which the cut is going has
minimum flow. Moreover, we only count edges that entering the cut.
Min-cut travels from top to bottom
In below example, the edge with cross will not be counted because if we think of it as an edge lying
horizontal from left to right, the red arc will be passing through under it, not above it and so it will not be
counted.
NOTE:
If an edge is in down to up direction, and the minimum cut line is crossing it from the left side, then it will
be counted, otherwise, not.
If an edge is in up to down direction, and the minimum cut line is crossing it from right, then it will be
counted, otherwise not.
If an edge is in horizontal direction, from left to right, and the minimum cut line is cross it from top to
down it will be counted, otherwise not
class Main
{
static final int V = 6; //Number of vertices in graph
}
}