Dinic's algorithm or Dinitz's algorithm is a
strongly polynomial
In computer science, a '' polynomial-time algorithm'' is generally speaking an algorithm whose running time is upper-bounded by some polynomial function of the input size. The definition naturally depends on the computational model, which determi ...
algorithm for computing the
maximum flow
In optimization theory, maximum flow problems involve finding a feasible flow through a flow network that obtains the maximum possible flow rate.
The maximum flow problem can be seen as a special case of more complex network flow problems, such ...
in a
flow network
In graph theory, a flow network (also known as a transportation network) is a directed graph where each edge has a capacity and each edge receives a flow. The amount of flow on an edge cannot exceed the capacity of the edge. Often in operations re ...
, conceived in 1970 by Israeli (formerly Soviet) computer scientist
Yefim Dinitz.
The algorithm runs in
time and is similar to the
Edmonds–Karp algorithm
In computer science, the Edmonds–Karp algorithm is an implementation of the Ford–Fulkerson method for computing the maximum flow in a flow network in O(, V, , E, ^2) time. The algorithm was first published by Yefim Dinitz in 1970, and indep ...
, which runs in
time, in that it uses shortest augmenting paths. The introduction of the concepts of the ''level graph'' and ''blocking flow'' enable Dinic's algorithm to achieve its performance.
History
Dinitz invented the algorithm in January 1969, as a master's student in
Georgy Adelson-Velsky
Georgy Maximovich Adelson-Velsky (; name is sometimes transliterated as Georgii Adelson-Velskii) (8 January 1922 – 26 April 2014) was a Soviet mathematician and computer scientist.
Born in Samara, Adelson-Velsky was originally educated as ...
's group. A few decades later, he would recall:
[
In 1970, Dinitz published a description of the algorithm in ''Doklady Akademii Nauk SSSR''. In 1974, Shimon Even and (his then Ph.D. student) Alon Itai at the Technion in Haifa were very curious and intrigued by Dinitz's algorithm as well as Alexander V. Karzanov's related idea of blocking flow. However it was hard for them to decipher these two papers, each being limited to four pages to meet the restrictions of journal ''Doklady Akademii Nauk SSSR''. Even did not give up, and after three days of effort managed to understand both papers except for the layered network maintenance issue. Over the next couple of years, Even gave lectures on "Dinic's algorithm", mispronouncing the name of the author while popularizing it. Even and Itai also contributed to this algorithm by combining BFS and ]DFS DFS may refer to:
Brands and enterprises
* Dancer Fitzgerald Sample, advertising agency, now Saatchi & Saatchi
* DFS Furniture, a furniture retailer in the United Kingdom and Ireland
* DFS Group (Duty Free Shoppers), Hong Kong
* DFS Program Exchang ...
, which is how the algorithm is now commonly presented.[
For about 10 years of time after the Ford–Fulkerson algorithm was invented, it was unknown if it could be made to terminate in polynomial time in the general case of irrational edge capacities. This caused a lack of any known polynomial-time algorithm to solve the max flow problem in generic cases. Dinitz's algorithm and the ]Edmonds–Karp algorithm
In computer science, the Edmonds–Karp algorithm is an implementation of the Ford–Fulkerson method for computing the maximum flow in a flow network in O(, V, , E, ^2) time. The algorithm was first published by Yefim Dinitz in 1970, and indep ...
(published in 1972) both independently showed that in the Ford–Fulkerson algorithm, if each augmenting path is the shortest one, then the length of the augmenting paths is non-decreasing and the algorithm always terminates.
Definition
Let be a network with and the capacity and the flow of the edge , respectively.
:The residual capacity is a mapping defined as,
:# if ,
:#:
:# if ,
:#:
:# otherwise.
:The residual graph is an unweighted graph , where
:: .
:An augmenting path is an – path in the residual graph .
:Define to be the length of the shortest path from to in . Then the level graph of is the graph , where
:: .
:A blocking flow is an – flow such that the graph with contains no – path. [This means that the subgraph resulting from removing all saturated edges (edges with ) does not contain any path from to . In other terms, the ''blocking flow'' is such that every possible path from to contains a saturated edge.]
Algorithm
Dinic's Algorithm
: ''Input'': A network .
: ''Output'': An – flow of maximum value.
# Set for each .
# Construct from of . If , stop and output .
# Find a blocking flow in .
# Augment flow by and go back to step 2.
Analysis
It can be shown that the number of layers in each blocking flow increases by at least 1 each time and thus there are at most blocking flows in the algorithm. For each of them:
* the level graph can be constructed by breadth-first search
Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next dept ...
in time
* a blocking flow in the level graph can be found in time[Finding the blocking flow can be implemented in per path via a sequence of Advance and Retreat operations. See http://courses.csail.mit.edu/6.854/06/scribe/scribe11.pdf for more details.]
with total running time for each layer. As a consequence, the running time of Dinic's algorithm is .
Using a data structure called dynamic trees
A link/cut tree is a data structure for representing a forest (graph theory), forest, a set of rooted trees, and offers the following operations:
* Add a tree consisting of a single node to the forest.
* Given a node in one of the trees, disco ...
, the running time of finding a blocking flow in each phase can be reduced to and therefore the running time of Dinic's algorithm can be improved to .
Special cases
In networks with unit capacities, a much stronger time bound holds. Each blocking flow can be found in time, and it can be shown that the number of phases does not exceed and .[The bound assumes that no two edges connect the same pair of vertices in the same direction, while the bound makes no such assumption.] Thus the algorithm runs in time.
In networks that arise from the bipartite matching problem, the number of phases is bounded by , therefore leading to the time bound. The resulting algorithm is also known as Hopcroft–Karp algorithm
In computer science, the Hopcroft–Karp algorithm (sometimes more accurately called the Hopcroft–Karp–Karzanov algorithm) is an algorithm that takes a bipartite graph as input and produces a maximum-cardinality matching as output — a set ...
. More generally, this bound holds for any ''unit network'' — a network in which each vertex, except for source and sink, either has a single entering edge of capacity one, or a single outgoing edge of capacity one, and all other capacities are arbitrary integers.
Example
The following is a simulation of Dinic's algorithm. In the level graph , the vertices with labels in red are the values . The paths in blue form a blocking flow.
See also
* Ford–Fulkerson algorithm
The Ford–Fulkerson method or Ford–Fulkerson algorithm (FFA) is a greedy algorithm that computes the maximum flow in a flow network. It is sometimes called a "method" instead of an "algorithm" as the approach to finding augmenting paths in a r ...
* Maximum flow problem
In Optimization (mathematics), optimization theory, maximum flow problems involve finding a feasible flow through a flow network that obtains the maximum possible flow rate.
The maximum flow problem can be seen as a special case of more complex ...
Notes
References
*
*
*
*
{{Optimization algorithms, combinatorial
Network flow problem
Graph algorithms