Dinic's algorithm
   HOME

TheInfoList



OR:

Dinic's algorithm or Dinitz's algorithm is a
strongly polynomial In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by t ...
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 (Chaim) A. Dinitz. The algorithm runs in O(V^2 E) time and is similar to the Edmonds–Karp algorithm, which runs in O(VE^2) 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 Adelson-Velsky's algorithms class. At the time he was not aware of the basic facts regarding the Ford–Fulkerson algorithm. Dinitz mentions inventing his algorithm in January 1969, which was published in 1970 in the journal ''Doklady Akademii Nauk SSSR''. In 1974,
Shimon Even Shimon Even ( he, שמעון אבן; June 15, 1935 – May 1, 2004) was an Israeli computer science researcher. His main topics of interest included algorithms, graph theory and cryptography. He was a member of the Computer Science Department at ...
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, 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 (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 G = ((V,E),c,f,s,t) be a network with c(u,v) and f(u,v) the capacity and the flow of the edge (u,v), respectively. :The residual capacity is a mapping c_f\colon V\times V \to R^+ defined as, :# if (u,v)\in E, :#: c_f(u,v) = c(u,v) - f(u,v) :# if (v,u)\in E, :#: c_f(u,v) = f(v,u) :# c_f(u,v) = 0 otherwise. :The residual graph is an unweighted graph G_f = ((V, E_f), c_f, _, s, t), where :: E_f = \. :An augmenting path is an st path in the residual graph G_f. :Define \operatorname(v) to be the length of the shortest path from s to v in G_f. Then the level graph of G_f is the graph G_L = ((V, E_L), c_f, _, s,t), where :: E_L = \. :A blocking flow is an st flow f' such that the graph G' = ((V,E_L'), s, t) with E_L' = \ contains no st path. This means that the subgraph resulting from removing all saturated edges (edges (u,v) with f'(u,v)=c_f, _(u,v)) does not contain any path from s to t. In other terms, the ''blocking flow'' is such that every possible path from s to t contains a saturated edge.


Algorithm

Dinic's Algorithm : ''Input'': A network G = ((V, E), c, s, t). : ''Output'': An st flow f of maximum value. # Set f(e) = 0 for each e\in E. # Construct G_L from G_f of G. If \operatorname(t) = \infty, stop and output f. # Find a blocking flow f' in G_L. # Add augment flow f by f' 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 , V, -1 blocking flows in the algorithm. For each of them: * the level graph G_L 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 de ...
in O(E) time * a blocking flow in the level graph G_L can be found in O(VE) timeFinding the blocking flow can be implemented in O(E) 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 O(E + VE) = O(VE) for each layer. As a consequence, the running time of Dinic's algorithm is O(V^2 E). Using a data structure called dynamic trees, the running time of finding a blocking flow in each phase can be reduced to O(E \log V) and therefore the running time of Dinic's algorithm can be improved to O(VE \log V).


Special cases

In networks with unit capacities, a much stronger time bound holds. Each blocking flow can be found in O(E) time, and it can be shown that the number of phases does not exceed O(\sqrt) and O(V^). Thus the algorithm runs in O(\min\E) time. In networks that arise from the
bipartite matching In the mathematical discipline of graph theory, a matching or independent edge set in an undirected graph is a set of edges without common vertices. Finding a matching in a bipartite graph can be treated as a network flow problem. Definit ...
problem, the number of phases is bounded by O(\sqrt), therefore leading to the O(\sqrt E) 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 of ...
. 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 G_L, the vertices with labels in red are the values \operatorname(v). The paths in blue form a blocking flow.


See also

* Ford–Fulkerson algorithm * Maximum flow problem


Notes


References

* * * {{Optimization algorithms, combinatorial Network flow problem Graph algorithms