词条 | Push–relabel maximum flow algorithm | |||||||||||
释义 |
In mathematical optimization, the push–relabel algorithm (alternatively, preflow–push algorithm) is an algorithm for computing maximum flows. The name "push–relabel" comes from the two basic operations used in the algorithm. Throughout its execution, the algorithm maintains a "preflow" and gradually converts it into a maximum flow by moving flow locally between neighboring nodes using push operations under the guidance of an admissible network maintained by relabel operations. In comparison, the Ford–Fulkerson algorithm performs global augmentations that send flow following paths from the source all the way to the sink. The push–relabel algorithm is considered one of the most efficient maximum flow algorithms. The generic algorithm has a strongly polynomial {{math|O(V 2E)}} time complexity, which is asymptotically more efficient than the {{math|O(VE 2)}} Edmonds–Karp algorithm.[2] Specific variants of the algorithms achieve even lower time complexities. The variant based on the highest label node selection rule has {{math|O(V 2{{sqrt|E}})}} time complexity and is generally regarded as the benchmark for maximum flow algorithms.[3][4] Subcubic {{math|O(VElog(V 2/E))}} time complexity can be achieved using dynamic trees, although in practice it is less efficient.[2] The push–relabel algorithm has been extended to compute minimum cost flows.[6] The idea of distance labels has led to a more efficient augmenting path algorithm, which in turn can be incorporated back into the push–relabel algorithm to create a variant with even higher empirical performance.[4][8] HistoryThe concept of a preflow was originally designed by Alexander V. Karzanov and was published in 1974 in Soviet Mathematical Dokladi 15. This pre-flow algorithm also used a push operation; however, it used distances in the auxiliary network to determine where to push the flow instead of a labeling system.[2][10] The push-relabel algorithm was designed by Andrew V. Goldberg and Robert Tarjan. The algorithm was initially presented in November 1986 in STOC '86: Proceedings of the eighteenth annual ACM symposium on Theory of computing, and then officially in October 1988 as an article in the Journal of the ACM. Both papers detail a generic form of the algorithm terminating in {{math|O(V 2E)}} along with a {{math|O(V 3)}} sequential implementation, a {{math|O(VElog(V 2/E))}} implementation using dynamic trees, and parallel/distributed implementation.[2][12]. A explained in [13] Goldberg-Tarjan introduced distance labels by incorporating them into the parallel maximum flow algorithm of Yossi Shiloach and Uzi Vishkin [14]. ConceptsDefinitions and notations{{main|Flow network}}Let:
and
The push–relabel algorithm uses a nonnegative integer valid labeling function which makes use of distance labels, or heights, on nodes to determine which arcs should be selected for the push operation. This labeling function is denoted by {{math|𝓁 : V → ℕ}}. This function must satisfy the following conditions in order to be considered valid: Valid labeling: {{math|𝓁(u) ≤ 𝓁(v) + 1}} for all {{math|(u, v) ∈ Ef}} Source condition: {{math|𝓁(s) {{=}} {{!}} V {{!}}}} Sink conservation: {{math|𝓁(t) {{=}} 0}} In the algorithm, the label values of {{mvar|s}} and {{mvar|t}} are fixed. {{math|𝓁(u)}} is a lower bound of the unweighted distance from {{mvar|u}} to {{mvar|t}} in {{math|Gf}} if {{mvar|t}} is reachable from {{mvar|u}}. If {{mvar|u}} has been disconnected from {{mvar|t}}, then {{math|𝓁(u) − {{!}} V {{!}}}} is a lower bound of the unweighted distance from {{mvar|u}} to {{mvar|s}}. As a result, if a valid labeling function exists, there are no {{math|s-t}} paths in {{math|Gf}} because no such paths can be longer than {{math|{{!}} V {{!}} − 1}}. An arc {{math|(u, v) ∈ Ef}} is called admissible if {{math|𝓁(u) {{=}} 𝓁(v) + 1}}. The admissible network {{math|G̃f (V, Ẽf )}} is composed of the set of arcs {{math|e ∈ Ef}} that are admissible. The admissible network is acyclic. OperationsInitializationThe algorithm starts by creating a residual graph, initializing the preflow values to zero and performing a set of saturating push operations on residual arcs exiting the source, {{math|(s, v) where v ∈ V \\ {{(}}s{{)}}}}. Similarly, the labels are initialized such that the label at the source is the number of nodes in the graph, {{math|𝓁(s) {{=}} {{!}} V {{!}}}}, and all other nodes are given a label of zero. Once the initialization is complete the algorithm repeatedly performs either the push or relabel operations against active nodes until no applicable operation can be performed. PushThe push operation applies on an admissible out-arc {{math|(u, v)}} of an active node {{mvar|u}} in {{math|Gf}}. It moves {{math|min{{(}}xf (u), cf (u,v){{)}}}} units of flow from {{mvar|u}} to {{mvar|v}}. push(u, v): assert xf[u] > 0 and 𝓁[u] == 𝓁[v] + 1 Δ = min(xf[u], c[u][v] - f[u][v]) f[u][v] += Δ f[v][u] -= Δ xf[u] -= Δ xf[v] += Δ A push operation that causes {{math|f (u, v)}} to reach {{math|c(u, v)}} is called a saturating push since it uses up all the available capacity of the residual arc. Otherwise, all of the excess at the node is pushed across the residual arc. This is called an unsaturating or non-saturating push. RelabelThe relabel operation applies on an active node {{mvar|u}} without any admissible out-arcs in {{math|Gf}}. It modifies {{math|𝓁(u)}} to be the minimum value such that an admissible out-arc is created. Note that this always increases {{math|𝓁(u)}} and never creates a steep arc, which is an arc {{math|(u, v)}} such that {{math|cf (u, v) > 0}}, and {{math|𝓁(u) > 𝓁(v) + 1}}. relabel(u): assert xf[u] > 0 and 𝓁[u] <= 𝓁[v] for all v such that c[u][v] - f[u][v] > 0 𝓁[u] = min(𝓁[v] for all v such that c[u][v] - f[u][v] > 0) + 1 Effects of push and relabelAfter a push or relabel operation, {{math|𝓁}} remains a valid labeling function with respect to {{mvar|f}}. For a push operation on an admissible arc {{math|(u, v)}}, it may add an arc {{math|(v, u)}} to {{math|Ef}}, where {{math|𝓁(v) {{=}} 𝓁(u) − 1 ≤ 𝓁(u) + 1}}; it may also remove the arc {{math|(u, v)}} from {{math|Ef}}, where it effectively removes the constraint {{math|𝓁(u) ≤ 𝓁(v) + 1}}. To see that a relabel operation on node {{mvar|u}} preserves the validity of {{math|𝓁(u)}}, notice that this is trivially guaranteed by definition for the out-arcs of u in {{math|Gf}}. For the in-arcs of {{mvar|u}} in {{math|Gf}}, the increased {{math|𝓁(u)}} can only satisfy the constraints less tightly, not violate them. The generic push–relabel algorithmThe generic push–relabel algorithm is used as a proof of concept only and does not contain implementation details on how to select an active node for the push and relabel operations. This generic version of the algorithm will terminate in {{math|O(V2E)}}. Since {{math|𝓁(s) {{=}} {{!}} V {{!}}}}, {{math|𝓁(t) {{=}} 0}}, and there are no paths longer than {{math|{{!}} V {{!}} − 1}} in {{math|Gf}}, in order for {{math|𝓁(s)}} to satisfy the valid labeling condition {{mvar|s}} must be disconnected from {{mvar|t}}. At initialisation, the algorithm fulfills this requirement by creating a pre-flow {{mvar|f}} that saturates all out-arcs of {{mvar|s}}, after which {{math|𝓁(v) {{=}} 0}} is trivially valid for all {{math|v ∈ V \\ {{(}}s, t{{)}}}}. After initialisation, the algorithm repeatedly executes an applicable push or relabel operation until no such operations apply, at which point the pre-flow has been converted into a maximum flow. generic-push-relabel(G, c, s, t): create a pre-flow f that saturates all out-arcs of s let 𝓁[s] = |V| let 𝓁[v] = 0 for all v ∈ V \\ {s} while there is an applicable push or relabel operation execute the operation CorrectnessThe algorithm maintains the condition that {{math|𝓁}} is a valid labeling during its execution. This can be proven true by examining the effects of the push and relabel operations on the label function {{math|𝓁}}. The relabel operation increases the label value by the associated minimum plus one which will always satisfy the {{math|𝓁(u) ≤ 𝓁(v) + 1}} constraint. The push operation can send flow from {{mvar|u}} to {{mvar|v}} if {{math|𝓁(u) {{=}} 𝓁(v) + 1}}. This may add {{math|(v, u)}} to {{math|Gf }} and may delete {{math|(u, v)}} from {{math|Gf }}. The addition of {{math|(v, u)}} to {{math|Gf }} will not affect the valid labeling since {{math|𝓁(v) {{=}} 𝓁(u) - 1}}. The deletion of {{math|(u, v)}} from {{math|Gf }} removes the corresponding constraint since the valid labeling property {{math|𝓁(u) ≤ 𝓁(v) + 1}} only applies to residual arcs in {{math|Gf }}.[12] If a preflow {{mvar|f}} and a valid labeling {{math|𝓁}} for {{mvar|f}} exists then there is no augmenting path from {{mvar|s}} to {{mvar|t}} in the residual graph {{math|Gf }}. This can be proven by contradiction based on inequalities which arise in the labeling function when supposing that an augmenting path does exist. If the algorithm terminates, then all nodes in {{math|V \\ {{(}}s, t{{)}}}} are not active. This means all {{math|v ∈ V \\ {{(}}s, t{{)}}}} have no excess flow, and with no excess the preflow {{mvar|f}} obeys the flow conservation constraint and can be considered a normal flow. This flow is the maximum flow according to the max-flow min-cut theorem since there is no augmenting path from {{mvar|s}} to {{mvar|t}}.[12] Therefore, the algorithm will return the maximum flow upon termination. Time complexityIn order to bound the time complexity of the algorithm, we must analyze the number of push and relabel operations which occur within the main loop. The numbers of relabel, saturating push and nonsaturating push operations are analyzed separately. In the algorithm, the relabel operation can be performed at most {{math|(2{{!}} V {{!}} - 1)({{!}} V {{!}} - 2) < 2{{!}} V {{!}}2}} times. This is because the labeling {{math|𝓁(u)}} value for any node u can never decrease, and the maximum label value is at most {{math|2{{!}} V {{!}} - 1}} for all nodes. This means the relabel operation could potentially be performed {{math|2{{!}} V {{!}} - 1 }} times for all nodes {{math|V \\ {{(}}s, t{{)}}}} (i.e. {{math|{{!}} V {{!}} - 2}}). This results in a bound of {{math|O(V 2)}} for the relabel operation. Each saturating push on an admissible arc {{math|(u, v)}} removes the arc from {{math|Gf }}. For the arc to be reinserted into {{math|Gf }} for another saturating push, {{mvar|v}} must first be relabeled, followed by a push on the arc {{math|(v, u)}}, then {{mvar|u}} must be relabeled. In the process, {{math|𝓁(u)}} increases by at least two. Therefore, there are {{math|O(V)}} saturating pushes on {{math|(u, v)}}, and the total number of saturating pushes is at most {{math|2{{!}} V {{!}}{{!}} E {{!}}}}. This results in a time bound of {{math|O(VE)}} for the saturating push operations. Bounding the number of nonsaturating pushes can be achieved via a potential argument. We use the potential function {{math|Φ {{=}} ∑[u ∈ V ∧ xf (u) > 0] 𝓁(u)}} (i.e. {{math|Φ}} is the sum of the labels of all active nodes). It is obvious that {{math|Φ}} is {{math|0}} initially and stays nonnegative throughout the execution of the algorithm. Both relabels and saturating pushes can increase {{math|Φ}}. However, the value of {{math|Φ}} must be equal to 0 at termination since there cannot be any remaining active nodes at the end of the algorithm's execution. This means that over the execution of the algorithm, the nonsaturating pushes must make up the difference of the relabel and saturating push operations in order for {{math|Φ}} to terminate with a value of 0. The relabel operation can increase {{math|Φ}} by at most {{math|(2{{!}} V {{!}} - 1)({{!}} V {{!}} - 2)}}. A saturating push on {{math|(u, v)}} activates {{mvar|v}} if it was inactive before the push, increasing {{math|Φ}} by at most {{math|2{{!}} V {{!}} - 1}}. Hence, the total contribution of all saturating pushes operations to {{math|Φ}} is at most {{math|(2{{!}} V {{!}} - 1)(2{{!}} V {{!}}{{!}} E {{!}})}}. A nonsaturating push on {{math|(u, v)}} always deactivates {{mvar|u}}, but it can also activate {{mvar|v}} as in a saturating push. As a result, it decreases {{math|Φ}} by at least {{math|𝓁(u) − 𝓁(v) {{=}} 1}}. Since relabels and saturating pushes increase {{math|Φ}}, the total number of nonsaturating pushes must make up the difference of {{math|(2{{!}} V {{!}} - 1)({{!}} V {{!}} - 2) + (2{{!}} V {{!}} - 1)(2{{!}} V {{!}}{{!}} E {{!}}) ≤ 4{{!}} V {{!}}2{{!}} E {{!}}}}. This results in a time bound of {{math|O(V 2E)}} for the nonsaturating push operations. In sum, the algorithm executes {{math|O(V 2)}} relabels, {{math|O(VE)}} saturating pushes and {{math|O(V 2E)}} nonsaturating pushes. Data structures can be designed to pick and execute an applicable operation in {{math|O(1)}} time. Therefore, the time complexity of the algorithm is {{math|O(V 2E)}}.[12] ExampleThe following is a sample execution of the generic push-relabel algorithm, as defined above, on the following simple network flow graph diagram. {{multiple image| align = center | width = 350 | image1 = Push Relabel Algoritm Example - Initial Graph.svg | alt1 = Initial flow network graph | caption1 = Initial flow network graph | image2 = Push-Relabel Algorithm Example - Final Network Graph.svg | alt2 = Final maximum flow network graph | caption2 = Final maximum flow network graph{{clear}} In the example, the {{nowrap|h}} and {{nowrap|e}} values denote the label {{math|𝓁}} and excess {{math|xf }}, respectively, of the node during the execution of the algorithm. Each residual graph in the example only contains the residual arcs with a capacity larger than zero. Each residual graph may contain multiple iterations of the {{nowrap|perform operation}} loop. {{clear}}
The example (but with initial flow of 0) can be run here interactively. Practical implementationsWhile the generic push–relabel algorithm has {{math|O(V 2E)}} time complexity, efficient implementations achieve {{math|O(V 3)}} or lower time complexity by enforcing appropriate rules in selecting applicable push and relabel operations. The empirical performance can be further improved by heuristics. "Current-arc" data structure and discharge operationThe "current-arc" data structure is a mechanism for visiting the in- and out-neighbors of a node in the flow network in a static circular order. If a singly linked list of neighbors is created for a node, the data structure can be as simple as a pointer into the list that steps through the list and rewinds to the head when it runs off the end. Based on the "current-arc" data structure, the discharge operation can be defined. A discharge operation applies on an active node and repeatedly pushes flow from the node until it becomes inactive, relabeling it as necessary to create admissible arcs in the process. discharge(u): while xf[u] > 0 if current-arc[u] has run off the end of neighbors[u] relabel(u) rewind current-arc[u] else let (u, v) = current-arc[u] if (u, v) is admissible push(u, v) let current-arc[u] point to the next neighbor of u Active node selection rulesDefinition of the discharge operation reduces the push–relabel algorithm to repeatedly selecting an active node to discharge. Depending on the selection rule, the algorithm exhibits different time complexities. For the sake of brevity, we ignore {{mvar|s}} and {{mvar|t}} when referring to the nodes in the following discussion. FIFO selection ruleThe FIFO push–relabel algorithm[2] organizes the active nodes into a queue. The initial active nodes can be inserted in arbitrary order. The algorithm always removes the node at the front of the queue for discharging. Whenever an inactive node becomes active, it is appended to the back of the queue. The algorithm has {{math|O(V 3)}} time complexity. Relabel-to-front selection ruleThe relabel-to-front push–relabel algorithm organizes all nodes into a linked list and maintains the invariant that the list is topologically sorted with respect to the admissible network. The algorithm scans the list from front to back and performs a discharge operation on the current node if it is active. If the node is relabeled, it is moved to the front of the list, and the scan is restarted from the front. The algorithm also has {{math|O(V 3)}} time complexity. Highest label selection ruleThe highest-label push–relabel algorithm[21] organizes all nodes into buckets indexed by their labels. The algorithm always selects an active node with the largest label to discharge. The algorithm has {{math|O(V 2{{sqrt|E}})}} time complexity. If the lowest-label selection rule is used instead, the time complexity becomes {{math|O(V 2E)}}.[3] Implementation techniquesAlthough in the description of the generic push–relabel algorithm above, {{math|𝓁(u)}} is set to zero for each node u other than {{mvar|s}} and {{mvar|t}} at the beginning, it is preferable to perform a backward breadth-first search from {{mvar|t}} to compute exact labels.[2] The algorithm is typically separated into two phases. Phase one computes a maximum pre-flow by discharging only active nodes whose labels are below {{mvar|n}}. Phase two converts the maximum preflow into a maximum flow by returning excess flow that cannot reach {{mvar|t}} to {{mvar|s}}. It can be shown that phase two has {{math|O(VE)}} time complexity regardless of the order of push and relabel operations and is therefore dominated by phase one. Alternatively, it can be implemented using flow decomposition.[13] Heuristics are crucial to improving the empirical performance of the algorithm.[25] Two commonly used heuristics are the gap heuristic and the global relabeling heuristic.[2][27] The gap heuristic detects gaps in the labeling function. If there is a label {{nowrap|0 < 𝓁{{'}} < {{!}} V {{!}}}} for which there is no node {{mvar|u}} such that {{math|𝓁(u) {{=}} 𝓁{{'}}}}, then any node {{mvar|u}} with {{math|𝓁{{'}} < 𝓁(u) < {{!}} V {{!}}}} has been disconnected from {{mvar|t}} and can be relabeled to {{math|({{!}} V {{!}} + 1)}} immediately. The global relabeling heuristic periodically performs backward breadth-first search from {{mvar|t}} in {{math|Gf }} to compute the exact labels of the nodes. Both heuristics skip unhelpful relabel operations, which are a bottleneck of the algorithm and contribute to the ineffectiveness of dynamic trees.[4] Sample implementations{{hidden begin|border=1px #aaa solid|titlestyle=text-align:center|title=C implementation}}{{hidden end}}{{hidden begin|border=1px #aaa solid|titlestyle=text-align:center|title=Python implementation}}{{hidden end}}References1. ^1 2 3 4 5 6 7 {{cite book|doi=10.1145/12130.12144|chapter=A new approach to the maximum flow problem|title=Proceedings of the eighteenth annual ACM symposium on Theory of computing - STOC '86|pages=136|year=1986|last1=Goldberg|first1=A V|last2=Tarjan|first2=R E|isbn=978-0897911931}} [1][2][3][4][5][6][7][8][9][10][11][12][13]2. ^1 2 3 4 {{cite journal|doi=10.1145/48014.61051|title=A new approach to the maximum-flow problem|journal=Journal of the ACM|volume=35|issue=4|pages=921|year=1988|last1=Goldberg|first1=Andrew V.|last2=Tarjan|first2=Robert E.}} 3. ^1 {{cite journal|doi=10.1016/0196-6774(82)90013-X|title=An O(n2log n) parallel max-flow algorithm|journal=Journal of Algorithms|volume=3|issue=2|pages=128–146|year=1982|last1=Shiloach|first1=Yossi|last2=Vishkin|first2=Uzi}} 4. ^{{cite journal|doi=10.1145/48014.61051|title=A new approach to the maximum-flow problem|journal=Journal of the ACM|volume=35|issue=4|pages=921|year=1988|last1=Goldberg|first1=Andrew V.|last2=Tarjan|first2=Robert E.}} 5. ^1 {{cite book|doi=10.1007/3-540-50517-2_69|chapter=Analysis of preflow push algorithms for maximum network flow|title=Foundations of Software Technology and Theoretical Computer Science|volume=338|pages=30|series=Lecture Notes in Computer Science|year=1988|last1=Cheriyan|first1=J.|last2=Maheshwari|first2=S. N.|isbn=978-3-540-50517-4}} 6. ^1 {{cite journal|doi=10.1007/BF01415937|title=Implementing Goldberg's max-flow-algorithm ? A computational investigation|journal=ZOR Zeitschrift für Operations Research Methods and Models of Operations Research|volume=33|issue=6|pages=383|year=1989|last1=Derigs|first1=U.|last2=Meier|first2=W.}} 7. ^1 {{cite journal|doi=10.1002/1520-6750(199106)38:3<413::AID-NAV3220380310>3.0.CO;2-J|title=Distance-directed augmenting path algorithms for maximum flow and parametric maximum flow problems|journal=Naval Research Logistics|volume=38|issue=3|pages=413|year=1991|last1=Ahuja|first1=Ravindra K.|last2=Orlin|first2=James B.|citeseerx=10.1.1.297.5698}} 8. ^1 2 {{Cite book | isbn = 978-0136175490 | title = Network Flows: Theory, Algorithms, and Applications | edition = 1st | last1 = Ahuja | first1 = R. K. | year = 1993 | publisher = Prentice Hall | last2 = Magnanti | first2 = T. L. | last3 = Orlin | first3 = J. B. | pages = }} 9. ^1 {{cite book|doi=10.1007/3-540-59408-6_49|chapter=On implementing push-relabel method for the maximum flow problem|title=Integer Programming and Combinatorial Optimization|volume=920|pages=157|series=Lecture Notes in Computer Science|year=1995|last1=Cherkassky|first1=Boris V.|last2=Goldberg|first2=Andrew V.|isbn=978-3-540-59408-6|citeseerx=10.1.1.150.3609}} 10. ^1 2 {{cite journal|doi=10.1016/S0377-2217(96)00269-X|title=Computational investigations of maximum flow algorithms|journal=European Journal of Operational Research|volume=97|issue=3|pages=509|year=1997|last1=Ahuja|first1=Ravindra K.|last2=Kodialam|first2=Murali|last3=Mishra|first3=Ajay K.|last4=Orlin|first4=James B.|citeseerx=10.1.1.297.2945}} 11. ^1 {{cite journal|doi=10.1006/jagm.1995.0805|title=An Efficient Implementation of a Scaling Minimum-Cost Flow Algorithm|journal=Journal of Algorithms|volume=22|pages=1–29|year=1997|last1=Goldberg|first1=Andrew V}} 12. ^1 2 3 {{cite book|doi=10.1007/978-3-540-87744-8_39|chapter=The Partial Augment–Relabel Algorithm for the Maximum Flow Problem|title=Algorithms - ESA 2008|volume=5193|pages=466–477|series=Lecture Notes in Computer Science|year=2008|last1=Goldberg|first1=Andrew V.|isbn=978-3-540-87743-1|citeseerx=10.1.1.150.5103}} 13. ^1 {{cite journal|doi=10.1145/2628036|title=Efficient maximum flow algorithms|journal=Communications of the ACM|volume=57|issue=8|pages=82|year=2014|last1=Goldberg|first1=Andrew V.|last2=Tarjan|first2=Robert E.}} }}{{DEFAULTSORT:Push-relabel maximum flow algorithm}} 2 : Network flow problem|Graph algorithms |
|||||||||||
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。