Dinic's algorithm
Dinic's algorithm or Dinitz's algorithm is a strongly polynomial algorithm for computing the maximum flow in a flow network, conceived in 1970 by Israeli (formerly Soviet) computer scientist Yefim (Chaim) A. Dinitz.[1] The algorithm runs in time and is similar to the Edmonds–Karp algorithm, 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
Yefim Dinitz invented this algorithm in response to a pre-class exercise in Adel'son-Vel'sky's (co-inventor of AVL trees) Algorithm class. At the time he was not aware of the basic facts regarding Ford-Fulkerson algorithm.[2]
Dinitz mentions inventing his algorithm in January 1969, which was published in 1970 in journal 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 the Dinitz's algorithm as well as Alexander Karzanov's idea of blocking flow. However it was hard to decipher these two papers for them, each being limited to four pages to meet the restrictions of journal Doklady Akademii nauk SSSR. However 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, which is the current version of algorithm[3]
For about 10 years of time after Ford–Fulkerson algorithm was invented, it was unknown if it can be made to terminate in polynomial time in the generic case of irrational edge capacities. This caused lack of any known polynomial time algorithm that solved max flow problem in generic case. Dinitz algorithm and the Edmonds–Karp algorithm, which was published in 1972, independently showed that in the Ford–Fulkerson algorithm, if each augmenting path is the shortest one, the length of the augmenting paths is non-decreasing and it always terminated.
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
,
-
-
otherwise.
- if
- The residual graph is the 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.
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 edges in each blocking flow increases by at least 1 each time and thus there are at most blocking flows in the algorithm, where
is the number of vertices in the network. The level graph
can be constructed by Breadth-first search in
time and a blocking flow in each level graph can be found in
time. Hence, the running time of Dinic's algorithm is
.
Using a data structure called dynamic trees, 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
. Thus the algorithm runs in
time.[4]
In networks arising during the solution of 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. 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.[5]
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.
![]() |
![]() |
![]() | |
---|---|---|---|
1. | ![]() |
![]() |
![]() |
The blocking flow consists of
Therefore the blocking flow is of 14 units and the value of flow | |||
2. | ![]() |
![]() |
![]() |
The blocking flow consists of
Therefore the blocking flow is of 5 units and the value of flow | |||
3. | ![]() |
![]() |
![]() |
Since | |||
See also
Notes
- ↑ Yefim Dinitz (1970). "Algorithm for solution of a problem of maximum flow in a network with power estimation" (PDF). Doklady Akademii nauk SSSR 11: 1277–1280.
- ↑ Ilan Kadar, Sivan Albagli (2009-11-27). "Dinitz's algorithm for finding a maximum flow in a network".
- ↑ Yefim Dinitz. "Dinitz's Algorithm: The Original Version and Even's Version" (PDF).
- ↑ Even, Shimon; Tarjan, R. Endre (1975). "Network Flow and Testing Graph Connectivity". SIAM Journal on Computing 4 (4): 507–518. doi:10.1137/0204043. ISSN 0097-5397.
- ↑ Tarjan 1983, p. 102.
References
- Yefim Dinitz (2006). "Dinitz' Algorithm: The Original Version and Even's Version" (PDF). In Oded Goldreich, Arnold L. Rosenberg, and Alan L. Selman. Theoretical Computer Science: Essays in Memory of Shimon Even. Springer. pp. 218–240. ISBN 978-3-540-32880-3.
- Tarjan, R. E. (1983). Data structures and network algorithms.
- B. H. Korte, Jens Vygen (2008). "8.4 Blocking Flows and Fujishige's Algorithm". Combinatorial Optimization: Theory and Algorithms (Algorithms and Combinatorics, 21). Springer Berlin Heidelberg. pp. 174–176. ISBN 978-3-540-71844-4.