Maximum flow in a network
In a graph where each edge has a given flow capacity the maximal flow between two vertices is calculated.
graph.maxflow(graph, source, target, capacity=NULL) graph.mincut(graph, source=NULL, target=NULL, capacity=NULL)
- The input graph.
- The id of the source vertex.
- The id of the target vertex (sometimes also called sink).
- Vector giving the capacity of the edges. If this is
NULL(the default) then the
capacityedge attribute is used.
graph.maxflow calculates the maximum flow between two vertices
in a weighted (ie. valued) graph. A flow from
target is an assignment of non-negative real numbers to the
edges of the graph, satisfying two properties: (1) for each edge the
flow (ie. the assigned number) is not more than the capacity of the
capacity parameter or edge attribute), (2) for every
vertex, except the source and the target the incoming flow is the same
as the outgoing flow. The value of the flow is the incoming flow of
target vertex. The maximum flow is the flow of maximum
graph.mincut calculates the minimum st-cut between two vertices
in a graph (if the
target arguments are
given) or the minimum cut of the graph (if both
The minimum st-cut between
target is the
minimum total weight of edges needed to remove to eliminate all paths from
The minimum cut of a graph is the minimum total weight of the edges
needed to remove to separate the graph into (at least) two
components. (Which is to make the graph not strongly connected
in the directed case.)
The maximum flow between two vertices in a graph is the same as the minimum
calculate the same quantity, the only difference is that
graph.mincut can be invoked without giving the
target arguments and then minimum of all possible minimum
cuts is calculated.
- A numeric constant, the maximum flow, or the minimum cut.
A. V. Goldberg and R. E. Tarjan: ``A New Approach to the Maximum Flow Problem'' Journal of the ACM 35:921-940, 1988.