<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.algo.informatik.tu-darmstadt.de/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BB91</id>
	<title>Algowiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.algo.informatik.tu-darmstadt.de/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BB91"/>
	<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/Special:Contributions/BB91"/>
	<updated>2026-05-23T23:54:08Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.38.4</generator>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dial_implementation&amp;diff=2810</id>
		<title>Dial implementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dial_implementation&amp;diff=2810"/>
		<updated>2015-02-26T09:57:47Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Checkup]]&lt;br /&gt;
[[Category:Data Structures]]&lt;br /&gt;
==General information==&lt;br /&gt;
'''Abstract data structure:''' [[Bounded monotonous priority queue]].&lt;br /&gt;
&lt;br /&gt;
'''Implementation invariant:'''&lt;br /&gt;
An object of &amp;quot;Dial implementation&amp;quot; comprises:&lt;br /&gt;
# A specific '''maximum span of keys''' &amp;lt;math&amp;gt;S\in\mathbb{N}&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An array &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; with index set &amp;lt;math&amp;gt;\{0,\ldots,S-1\}&amp;lt;/math&amp;gt; and [[Sets and sequences|sets]] of keys as components,&lt;br /&gt;
# A '''current position of the minimum''' &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt;, which is dynamically changing.&lt;br /&gt;
# An [[Index handler|index handler]], whose value type is a pointer to an element in a [[Sets and sequences|set]] of keys.&lt;br /&gt;
&lt;br /&gt;
All keys at an index of &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; are equal. For &amp;lt;math&amp;gt;i\in\{0,\ldots,S-1\}&amp;lt;/math&amp;gt;, the value of the keys at position &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; is larger than the value of the keys at index &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; by exactly &amp;lt;math&amp;gt;(S+i-P)\bmod S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For each key currently stored in &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;, the index handler contains a pointer to the corresponding set element.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
# '''Extract minimum:''' The minimum keys are found at position &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt;. If the set at position &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; is empty after extracting one minimum element, the current position &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; is increased by 1 modulo &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, &lt;br /&gt;
# '''Insert:''' A key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; is inserted at index &amp;lt;math&amp;gt;(K-A[P]+P)\bmod S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# '''Decrease key:''' Decreasing a key value &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; to value &amp;lt;math&amp;gt;K'&amp;lt;/math&amp;gt; amounts to removing the key from the set at index &amp;lt;math&amp;gt;(K-A[P]+P)\bmod S&amp;lt;/math&amp;gt; and re-insert it at index &amp;lt;math&amp;gt;(K'-A[P]+P)\bmod S&amp;lt;/math&amp;gt;. The set element is retrieved from the index handler.&lt;br /&gt;
&lt;br /&gt;
==Remark==&lt;br /&gt;
The implementations of the methods [[Bounded priority queue|Bounded priority queue: number]] and [[Bounded priority queue|Bounded priority queue: find minimum]] are trivial and, hence, left out here.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Matchings_in_graphs&amp;diff=2803</id>
		<title>Matchings in graphs</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Matchings_in_graphs&amp;diff=2803"/>
		<updated>2015-02-22T09:53:25Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Blossoms */ insgesamt häufiger u_B verwendet, daher nun in diese Richtung abgeändert&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Matchings ==&lt;br /&gt;
&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be an [[Basic graph definitions|undirected graph]]. Without loss of generality, &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is [[Basic graph definitions#Connectedness|connected]]. A '''matching''' in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is a set &amp;lt;math&amp;gt;M\subseteq E&amp;lt;/math&amp;gt; of edges such that no two edges in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; are [[Basic graph definitions#Adjacency, incidence, and degree|incident]].&lt;br /&gt;
# An edge in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is called '''matched''', an edge in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; is '''unmatched'''.&lt;br /&gt;
# A node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''matched''' with respect to a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if it is incident to a matched edge; otherwise, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is called '''free''' or '''exposed'''.&lt;br /&gt;
# A matching is called '''perfect''' if there is no exposed node.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
A perfect matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is only possible if &amp;lt;math&amp;gt;|V|&amp;lt;/math&amp;gt; is even. Then &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is perfect if, and only if, &amp;lt;math&amp;gt;|M|=|V|/2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Alternating and augmenting paths ==&lt;br /&gt;
&lt;br /&gt;
# A path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in an undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is called '''alternating''' with respect to some matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if, for any two successive edges on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, exactly one of them belongs to &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;. In other words, the edges in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; and the edges not in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; appear strictly alternatingly on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An alternating path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in an undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is called '''augmenting''' with respect to some matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if both of its end nodes are exposed.&lt;br /&gt;
# '''Augmenting''' a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; '''along an augmenting path''' &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; means increasing the size of &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; by one as follows:&lt;br /&gt;
## Each edge of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that was in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; immediately before this augmentation step, is removed from &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Each edge of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that was ''not'' in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; immediately before this augmentation step, is inserted in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Finding augmenting paths ==&lt;br /&gt;
&lt;br /&gt;
To find alternating paths in a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, a [[Graph traversal|graph traversal strategy]] is chosen and modified as follows: &lt;br /&gt;
# Whenever the current node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has been reached via an edge in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, only incident edges in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; are considered for seeing new nodes.&lt;br /&gt;
# Mirror-symmetrically, whenever the current node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has been reached via an edge in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt;, only the (unique) incident edge in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, if existing, is considered for seeing a new node.&lt;br /&gt;
To find augmenting paths, the start node must be an exposed node.&lt;br /&gt;
&lt;br /&gt;
'''Remark on the implementation:'''&lt;br /&gt;
This modified graph traversal in an undirected graph could be implemented as an ordinary graph traversal in a directed graph:&lt;br /&gt;
# Duplicate each matched node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;v_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;v_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Replace each edge &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; by two arcs, &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each matched node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;:&lt;br /&gt;
## Let all incoming arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; point to &amp;lt;math&amp;gt;v_1&amp;lt;/math&amp;gt; and all outgoing arcs in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; leave &amp;lt;math&amp;gt;v_1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Mirror-symmetrically, let all incoming arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; point to &amp;lt;math&amp;gt;v_2&amp;lt;/math&amp;gt; and all outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; leave &amp;lt;math&amp;gt;v_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Caveat:'''&lt;br /&gt;
If the graph is not [[Basic graph definitions#Bipartite and k-partite graphs|bipartite]], no [[Graph traversal|graph traversal strategies]], modified as described above, guarantees  to find an augmenting path if there is one; [[#Blossoms|blossom handling]] is necessary in addition.&lt;br /&gt;
&lt;br /&gt;
== Blossoms ==&lt;br /&gt;
&lt;br /&gt;
'''Definitions:'''&lt;br /&gt;
# For a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, a '''blossom''' is a cycle &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; of odd length in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;\lfloor|B|/2\rfloor&amp;lt;/math&amp;gt; edges on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; are matched and the remaining node on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is matched as well (by an edge not on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, in fact).&lt;br /&gt;
# The unique matched edge with exactly one incident node on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is called the '''stem''' of the blossom.&lt;br /&gt;
# '''Shrinking''' a blossom &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; means:&lt;br /&gt;
## Insert a new node &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;.&lt;br /&gt;
## For each edge &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is not: Replace &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; by a new edge &amp;lt;math&amp;gt;\{u_B,w\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Remove all nodes and edges on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An augmenting path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; '''conforms''' to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; contains the stem.&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be an undirected graph, &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; a matching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; a blossom. Further, let &amp;lt;math&amp;gt;G'=(V',E')&amp;lt;/math&amp;gt; be  the undirected graph resulting from shrinking &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, and let &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; be the restriction of &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. There is an augmenting path conforming to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if, and only if, there is an augmenting path in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; that contains &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First suppose there is a conforming augmenting path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;. According to either possible orientation of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; denote the first and the last node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Moreover, let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; denote the first and the last node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that also belongs to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; (possibly &amp;lt;math&amp;gt;v=w&amp;lt;/math&amp;gt;). The concatenation of the subpaths of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and from &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is an augmenting path in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, and this path contains &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
So, consider the case that there is an augmenting path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt;, and that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; contains &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;. Since &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt; is matched, &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt; is not an end node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; contains the stem of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; because this is the only matched edge incident to &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be the node of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; incident to the stem and let &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; be the node on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that is farthest away from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; among all nodes of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that also belong to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. Exactly one of the two subpaths of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; yields a conforming augmenting path by concatenation with the two subpaths of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the end nodes of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; up to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;, respectively.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Maximum_matching_by_Edmonds&amp;diff=2802</id>
		<title>Maximum matching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Maximum_matching_by_Edmonds&amp;diff=2802"/>
		<updated>2015-02-22T09:25:36Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */ Bezeichnung und Link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Cardinality-maximal matching]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Each recursive step returns a cardinality-maximal matching of its input graph.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
The number of nodes decreases.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
The graph search does not find an augmenting path, nor does it run into a [[Matchings in graphs#Blossoms|blossom]].&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
Apply the  [[Classical bipartite cardinality matching#Induction step|modified repeated graph search]] from the [[Classical bipartite cardinality matching|classical algorithm]] for the restriction to [[Basic graph definitions#Bipartite and k-partite graphs|bipartite graphs]]. More specifically, choose a [[Breadth-first search|BFS]] or another graph traversal strategy that will never return to the start node (this requirement excludes [[Depth-first search|DFS]]).&lt;br /&gt;
&lt;br /&gt;
The search maintains a boolean flag even/odd, which indicates the parity of the distance of the current node from the start node of the current search. Also, each node has a boolean label even/odd. When this node is seen for the first time, its label is set according to the flag. If a labeled node is seen again, but with another distance parity than before:&lt;br /&gt;
# The repeated graph search is terminated.&lt;br /&gt;
# A blossom &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is identified.&lt;br /&gt;
# &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is [[Matchings in graphs#Blossoms|shrunken]], giving &amp;lt;math&amp;gt;G'=(V',E')&amp;lt;/math&amp;gt; and the restriction &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The procedure is called recursively with &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Exactly one node of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is matched by &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt;, so extend &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; in the obvious, unique way by &amp;lt;math&amp;gt;\lfloor|B|/2\rfloor&amp;lt;/math&amp;gt; edges of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# This extension of &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; is returned.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
In typical formulations of this algorithm, the graph search is not left open but the search strategy applied in [[Hopcroft-Karp]] is hard-coded.&lt;br /&gt;
&lt;br /&gt;
'''Implementation of step 2:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; be the node on which the two different parities occur, and let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be the node from which &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is seen at that moment. In the arborescence constructed so far, let &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; denote the node such that the paths from the start node to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; coincide up to &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; and part at &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt;.  Note that the incoming edge of &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; in the arborescence is matched because, otherwise, the arborescence could not branch at &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt;. Therefore, the concatenation of the branch from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the branch from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; is a blossom, and the search entered this blossom via its stem.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show: If &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is not maximum, the graph search will either find an augmenting path or run into a blossom via its stem. Suppose the search does not find an augmenting path. Due to the proof in the [[Classical bipartite cardinality matching#Induction step|induction step]] of the [[Classical bipartite cardinality matching|classical bipartite cardinality matching algorithm]], the graph search runs into an odd cycle. Since we chose a graph search strategy that never returns to the start node, the remark on that proof implies that this odd cycle is a blossom, and that the search entered  this blossom via its stem.&lt;br /&gt;
&lt;br /&gt;
It remains to show that the returned extension of &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; is cardinality-maximal for &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; provided &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; is cardinality-maximal fpr &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. However, this follows immediately from the fundamental [[Matchings in graphs#Blossoms|statement about blossoms]].&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Follows immediately from the invariant.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic worst-case complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n\!\cdot\!m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|E|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Due to the variant, the recursion depth is in &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;. Each recursive step is dominated by the graph traversal. The [[Basic graph definitions#Adjacency, incidence, and degree|statement and remark on isolated nodes]] apply.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Classical_bipartite_cardinality_matching&amp;diff=2801</id>
		<title>Classical bipartite cardinality matching</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Classical_bipartite_cardinality_matching&amp;diff=2801"/>
		<updated>2015-02-22T08:49:07Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction step */ Korrektur Bezeichnung p''&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Cardinality-maximal matching|Cardinality-maximal matching]] in [[Basic graph definitions#Bipartite and k-partite graphs|bipartite graphs]].&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
&amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is a matching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
&amp;lt;math&amp;gt;|M|&amp;lt;/math&amp;gt; is increased by one.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
There is no more [[Matchings in graphs#Alternating and augmenting paths|augmenting path]].&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
Initialize &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; to be a feasible matching, for example, the empty matching.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Search for an [[Matchings in graphs#Alternating and augmenting paths|augmenting path]].&lt;br /&gt;
# If there is none, the loop terminates.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; denote the augmenting path found in step 1.&lt;br /&gt;
# [[Matchings in graphs#Alternating and augmenting paths|Augment]] &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; along &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementation of step 1:'''&lt;br /&gt;
A [[Graph traversal|graph traversal strategy]] is to be chosen that generates an [[Basic graph definitions#Forests, trees, branchings, arborescences|arborescence]] rooted at the start node, for example, a [[Depth-first search|DFS]] or a [[Breadth-first search|BFS]]. The [[Matchings in graphs#Finding augmenting paths|modification to find augmenting paths]] must be applied.&lt;br /&gt;
In a loop over all exposed nodes, a graph search is started at each of them. This loop may terminate early, namely when the first augmenting path is found.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Basically, we have to show that there is no more augmenting path if this repeated graph search does not find one. So suppose for a contradiction that a search from an exposed node &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; fails although there is an augmenting path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to some other exposed node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. Then &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not seen by this graph search. Let &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; be the last node on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; seen by this graph search, let &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt; denote the edge over which &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; was seen, and let &amp;lt;math&amp;gt;e'&amp;lt;/math&amp;gt; be the next edge on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; (as seen in the direction from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;). Since &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt; was considered by the graph search and &amp;lt;math&amp;gt;e'&amp;lt;/math&amp;gt; was not, we may conclude &amp;lt;math&amp;gt;e,e'\not\in M&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; be the subpath of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p''&amp;lt;/math&amp;gt; the path from &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; in the arborescence. As &amp;lt;math&amp;gt;e'\not\in M&amp;lt;/math&amp;gt;, the last edge of &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; has even length. Since &amp;lt;math&amp;gt;e\not\in M&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;p''&amp;lt;/math&amp;gt; has odd length. In summary, the concatenation &amp;lt;math&amp;gt;p'+p''&amp;lt;/math&amp;gt; is a (usually non-simple) cycle of odd length. In particular, &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is not bipartite.&lt;br /&gt;
&lt;br /&gt;
'''Remark on the proof:'''&lt;br /&gt;
Go from &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; backwards along &amp;lt;math&amp;gt;p''&amp;lt;/math&amp;gt; until the first node &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;, say, is seen that also belongs to &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. In case &amp;lt;math&amp;gt;y\neq u&amp;lt;/math&amp;gt;, the subpaths of &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p''&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; form a   [[Matchings in graphs#Blossoms|blossom]], and the graph search entered this blossom via its [[Matchings in graphs#Blossoms|stem]].&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
[[Cardinality-maximal matching#Berge's theorem|Berge's theorem]] immediately implies that the resulting matching is [[Sets and sequences#Maximal and minimal sets|cardinality-maximal]].&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n\!\cdot\!m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|E|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Since a matching cannot have more than &amp;lt;math&amp;gt;|V|/2&amp;lt;/math&amp;gt; edges, the number of iterations is linear in the number of nodes. The complexity of an iteration is dominated by the graph search. The [[Basic graph definitions#Adjacency, incidence, and degree|statement and remark on isolated nodes]] apply.&lt;br /&gt;
&lt;br /&gt;
== Connection to max-flow ==&lt;br /&gt;
&lt;br /&gt;
This algorithm may be interpreted as an application of [[Ford-Fulkerson]]:&lt;br /&gt;
# Let &amp;lt;math&amp;gt;\{V_1,V_2\}&amp;lt;/math&amp;gt; denote a [[Sets and sequences#Partitions|bipartition]] of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; such that each edge is incident to one node of &amp;lt;math&amp;gt;V_1&amp;lt;/math&amp;gt; and one node of &amp;lt;math&amp;gt;V_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Replace each undirected edge &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; by the directed arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; with infinite capacity, where &amp;lt;math&amp;gt;v\in V_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in V_2&amp;lt;/math&amp;gt; (so, all arcs go from &amp;lt;math&amp;gt;V_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V_2&amp;lt;/math&amp;gt;).&lt;br /&gt;
# Insert a new super-source &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and a new super-target &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V_1&amp;lt;/math&amp;gt;, insert an arc &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt; with capacity one.&lt;br /&gt;
# Mirror-symmetrically, for each node &amp;lt;math&amp;gt;w\in V_2&amp;lt;/math&amp;gt;, insert an arc &amp;lt;math&amp;gt;(w,t)&amp;lt;/math&amp;gt; with capacity one.&lt;br /&gt;
There is an obvious one-to-one correspondence between integral flows in that network and matchings in the original graph: An edge belongs to the matching if, and only if, the corresponding arc has positive flow value. The maximum flows correspond to the cardinality-maximal matchings. There is also a one-to-one correspondence between [[Matchings in graphs#Alternating and augmenting paths|augmenting paths]] in the original graph and [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting paths]] in the induced flow network. [[Matchings in graphs#Alternating and augmenting paths|Augmenting]] the matching along an augmenting path is tantamount to [[Basic flow definitions#Augmenting along a path|augmenting]] the flow along the corresponding flow-augmenting path. Finally, the [[Max-flow min-cut|max-flow min-cut theorem]] reduces to the famous min-max theorem for bipartite matchings:&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# A '''node cover''' in an undirected graph is a set of nodes such that each edge is incident to at least one node in this set.&lt;br /&gt;
# A node in a node cover is said to '''cover''' the edges incident to this node.&lt;br /&gt;
&lt;br /&gt;
'''Min-max theorem:'''&lt;br /&gt;
In a bipartite graph, the maximum cardinality of a matching equals the minimum cardinality of a node cover.&lt;br /&gt;
&lt;br /&gt;
'''Reduction to the max-flow min-cut theorem:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; be a cardinality-maximal matching. No node can cover more than one edge of &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;. Therefore, no node set of less than &amp;lt;math&amp;gt;|M|&amp;lt;/math&amp;gt; nodes can be a node cover. Thus, it suffices to construct a node cover of cardinality &amp;lt;math&amp;gt;|M|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The [[Max-flow min-cut|max-flow min-cut theorem]] implies that the minimum &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-cut &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; has capacity &amp;lt;math&amp;gt;|M|&amp;lt;/math&amp;gt;. In particular, &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; has finite capacity, so it is only crossed by arcs from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; and by arcs from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. Now, let &amp;lt;math&amp;gt;S':=S\cap V_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T':=T\cap V_1&amp;lt;/math&amp;gt;. By construction, the node sets &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T'&amp;lt;/math&amp;gt; are disjoint. The nodes in &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt; are in one-to-one correspondence to the arcs from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, and the nodes in &amp;lt;math&amp;gt;T'&amp;lt;/math&amp;gt; are in one-to-one correspondence to the arcs from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. In summary, &amp;lt;math&amp;gt;|S'\cup T'|&amp;lt;/math&amp;gt; is the capacity of &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt;. Hence, it suffices to show that &amp;lt;math&amp;gt;S'\cup T'&amp;lt;/math&amp;gt; is a node cover for the original graph.&lt;br /&gt;
&lt;br /&gt;
For a contradiction suppose some edge &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; is not covered, where &amp;lt;math&amp;gt;v\in V_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in V_2&amp;lt;/math&amp;gt;, say. So, it is &amp;lt;math&amp;gt;v\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in T&amp;lt;/math&amp;gt;, However, then &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; would go from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which contradicts the fact that the capacity of &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; is finite.&lt;br /&gt;
&lt;br /&gt;
'''Comment:'''&lt;br /&gt;
'''Tutte's theorem''' extends the min-max theorem to non-bipartite graphs.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Matchings_in_graphs&amp;diff=2800</id>
		<title>Matchings in graphs</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Matchings_in_graphs&amp;diff=2800"/>
		<updated>2015-02-22T08:06:32Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Blossoms */ einheitliche Bezeichnung des Parameters im Text&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Matchings ==&lt;br /&gt;
&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be an [[Basic graph definitions|undirected graph]]. Without loss of generality, &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is [[Basic graph definitions#Connectedness|connected]]. A '''matching''' in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is a set &amp;lt;math&amp;gt;M\subseteq E&amp;lt;/math&amp;gt; of edges such that no two edges in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; are [[Basic graph definitions#Adjacency, incidence, and degree|incident]].&lt;br /&gt;
# An edge in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is called '''matched''', an edge in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; is '''unmatched'''.&lt;br /&gt;
# A node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''matched''' with respect to a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if it is incident to a matched edge; otherwise, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is called '''free''' or '''exposed'''.&lt;br /&gt;
# A matching is called '''perfect''' if there is no exposed node.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
A perfect matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is only possible if &amp;lt;math&amp;gt;|V|&amp;lt;/math&amp;gt; is even. Then &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is perfect if, and only if, &amp;lt;math&amp;gt;|M|=|V|/2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Alternating and augmenting paths ==&lt;br /&gt;
&lt;br /&gt;
# A path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in an undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is called '''alternating''' with respect to some matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if, for any two successive edges on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, exactly one of them belongs to &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;. In other words, the edges in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; and the edges not in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; appear strictly alternatingly on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An alternating path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in an undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is called '''augmenting''' with respect to some matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if both of its end nodes are exposed.&lt;br /&gt;
# '''Augmenting''' a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; '''along an augmenting path''' &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; means increasing the size of &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; by one as follows:&lt;br /&gt;
## Each edge of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that was in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; immediately before this augmentation step, is removed from &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Each edge of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that was ''not'' in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; immediately before this augmentation step, is inserted in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Finding augmenting paths ==&lt;br /&gt;
&lt;br /&gt;
To find alternating paths in a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, a [[Graph traversal|graph traversal strategy]] is chosen and modified as follows: &lt;br /&gt;
# Whenever the current node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has been reached via an edge in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, only incident edges in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; are considered for seeing new nodes.&lt;br /&gt;
# Mirror-symmetrically, whenever the current node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has been reached via an edge in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt;, only the (unique) incident edge in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, if existing, is considered for seeing a new node.&lt;br /&gt;
To find augmenting paths, the start node must be an exposed node.&lt;br /&gt;
&lt;br /&gt;
'''Remark on the implementation:'''&lt;br /&gt;
This modified graph traversal in an undirected graph could be implemented as an ordinary graph traversal in a directed graph:&lt;br /&gt;
# Duplicate each matched node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;v_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;v_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Replace each edge &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; by two arcs, &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each matched node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;:&lt;br /&gt;
## Let all incoming arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; point to &amp;lt;math&amp;gt;v_1&amp;lt;/math&amp;gt; and all outgoing arcs in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; leave &amp;lt;math&amp;gt;v_1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Mirror-symmetrically, let all incoming arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;E\setminus M&amp;lt;/math&amp;gt; point to &amp;lt;math&amp;gt;v_2&amp;lt;/math&amp;gt; and all outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; leave &amp;lt;math&amp;gt;v_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Caveat:'''&lt;br /&gt;
If the graph is not [[Basic graph definitions#Bipartite and k-partite graphs|bipartite]], no [[Graph traversal|graph traversal strategies]], modified as described above, guarantees  to find an augmenting path if there is one; [[#Blossoms|blossom handling]] is necessary in addition.&lt;br /&gt;
&lt;br /&gt;
== Blossoms ==&lt;br /&gt;
&lt;br /&gt;
'''Definitions:'''&lt;br /&gt;
# For a matching &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, a '''blossom''' is a cycle &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; of odd length in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;\lfloor|B|/2\rfloor&amp;lt;/math&amp;gt; edges on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; are matched and the remaining node on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is matched as well (by an edge not on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, in fact).&lt;br /&gt;
# The unique matched edge with exactly one incident node on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is called the '''stem''' of the blossom.&lt;br /&gt;
# '''Shrinking''' a blossom &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; means:&lt;br /&gt;
## Insert a new node &amp;lt;math&amp;gt;v_B&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;.&lt;br /&gt;
## For each edge &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is not: Replace &amp;lt;math&amp;gt;\{v,w\}&amp;lt;/math&amp;gt; by a new edge &amp;lt;math&amp;gt;\{v_B,w\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Remove all nodes and edges on &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An augmenting path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; '''conforms''' to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; contains the stem.&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; be an undirected graph, &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; a matching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; a blossom. Further, let &amp;lt;math&amp;gt;G'=(V',E')&amp;lt;/math&amp;gt; be  the undirected graph resulting from shrinking &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, and let &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; be the restriction of &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. There is an augmenting path conforming to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; if, and only if, there is an augmenting path in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt; that contains &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First suppose there is a conforming augmenting path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;. According to either possible orientation of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; denote the first and the last node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Moreover, let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; denote the first and the last node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that also belongs to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; (possibly &amp;lt;math&amp;gt;v=w&amp;lt;/math&amp;gt;). The concatenation of the subpaths of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and from &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is an augmenting path in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, and this path contains &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
So, consider the case that there is an augmenting path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;M'&amp;lt;/math&amp;gt;, and that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; contains &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;. Since &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt; is matched, &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt; is not an end node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, so &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; contains the stem of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; because this is the only matched edge incident to &amp;lt;math&amp;gt;u_B&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be the node of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; incident to the stem and let &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; be the node on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that is farthest away from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; among all nodes of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that also belong to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. Exactly one of the two subpaths of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; yields a conforming augmenting path by concatenation with the two subpaths of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the end nodes of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; up to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;, respectively.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Successive_shortest_paths_with_reduced_costs&amp;diff=2799</id>
		<title>Successive shortest paths with reduced costs</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Successive_shortest_paths_with_reduced_costs&amp;diff=2799"/>
		<updated>2015-02-20T14:39:39Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Abstract view */ Vereinheitlichung Seitenaufbau&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Min-cost flow problem]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
For each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, there is a real number &amp;lt;math&amp;gt;\pi(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
# All points of the invariant of the [[Successive shortest paths|successive shortest paths]] algorithm.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a=(v,w)\in A_f&amp;lt;/math&amp;gt;, the '''reduced cost''' &amp;lt;math&amp;gt;c^\pi(a):=c(a)-\pi(v)+\pi(w)&amp;lt;/math&amp;gt; is nonnegative.&lt;br /&gt;
&lt;br /&gt;
'''Variant:''' The total imbalance strictly decreases.&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
Such a node labeling &amp;lt;math&amp;gt;\pi&amp;lt;/math&amp;gt; is called '''consistent''' with &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
Start with the zero flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; and with the zero node labeling &amp;lt;math&amp;gt;\pi&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The assumption that all cost values are nonnegative implies that &amp;lt;math&amp;gt;\pi\equiv 0&amp;lt;/math&amp;gt; is consistent with &amp;lt;math&amp;gt;f\equiv 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
The induction step is a variation and extension of the [[Successive shortest paths#Induction step|induction step]] of the [[Successive shortest paths|successive shortest paths algorithm]]. The essential modification is that &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; is replaced by &amp;lt;math&amp;gt;c^\pi&amp;lt;/math&amp;gt;. Due to point 2 of the invariant, it is always &amp;lt;math&amp;gt;c^\pi\geq 0&amp;lt;/math&amp;gt;. Therefore, an efficient algorithm such as [[Dijkstra|Dijkstra's]] may be applied. The extension is that, after each augmentation of the flow, the reduced cost values must be updated to maintain consistency.&lt;br /&gt;
&lt;br /&gt;
'''Implementation''' of the update of the reduced cost values:&lt;br /&gt;
For all nodes &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;\pi(v):=\pi(v)-\delta(v)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt; is the distance of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; as computed in the [[Successive shortest paths#Induction step|induction step]] of the [[Successive shortest paths|successive shortest paths algorithm]].&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The variant and points 1 and 3 of the invariant of the [[Successive shortest paths|successive shortest paths algorithm]] are obviously maintained. For point 2 of that invariant, it suffices to show that the shortest paths with respect to the arc lengths &amp;lt;math&amp;gt;c^\pi&amp;lt;/math&amp;gt; are also shortest paths with respect to the arc lengths &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;; however, that results immediately from [[Basics of shortest paths#(Admissible) node potentials|this statement]].&lt;br /&gt;
&lt;br /&gt;
It remains to show that the updated node potentials are consistent with the augmented flow. Let &amp;lt;math&amp;gt;\pi_\mathrm{before}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\pi_\mathrm{after}&amp;lt;/math&amp;gt; denote the values of &amp;lt;math&amp;gt;\pi&amp;lt;/math&amp;gt; immediately before and after the current iteration, respectively. Let &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; be an arc in the [[Basic flow definitions#Residual network|residual network]] of the augmented flow, that is, the flow immediately after the current iteration. We make a case distinction:&lt;br /&gt;
# If &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; was also in the residual network immediately before the current iteration, the new reduced cost of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;c^{\pi_\mathrm{after}}(v,w)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt; =c(v,w)-\pi_\mathrm{after}(v)+\pi_\mathrm{after}(w)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;=c(v,w)-\left[\pi_\mathrm{before}(v)-\delta(v)\right]+\left[\pi_\mathrm{before}(w)-\delta(w)\right]&amp;lt;/math&amp;gt; &amp;lt;matH&amp;gt;=c^{\pi_\mathrm{before}}(v,w)-\delta(w)+\delta(v)&amp;lt;/math&amp;gt;. As the &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;-values are shortest-path distances with respect to arc lengths &amp;lt;math&amp;gt;c^{\pi_\mathrm{before}}&amp;lt;/math&amp;gt;, the [[basics of shortest paths#Valid distance property|valid distance property]] yields &amp;lt;math&amp;gt;\delta(w)\leq\delta(v)+c^{\pi_\mathrm{before}}(v,w)&amp;lt;/math&amp;gt;, which proves the claim.&lt;br /&gt;
# Otherwise, &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt; is on the shortest path computed in the current iteration. Recall &amp;lt;math&amp;gt;c(v,w)=-c(w,v)&amp;lt;/math&amp;gt;, so we obtain &amp;lt;math&amp;gt;c^{\pi_\mathrm{after}}(v,w)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;=c(v,w)-\pi_\mathrm{after}(v)+\pi_\mathrm{after}(w)&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;=-\left[c(w,v)-\pi_\mathrm{after}(w)+\pi_\mathrm{after}(v)\right]&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;=-\left[c(w,v)-(\pi_\mathrm{before}(w)-\delta(w))+(\pi_\mathrm{before}(v)-\delta(v))\right]&amp;lt;/math&amp;gt; &amp;lt;math&amp;gt;=-\left[c^{\pi_\mathrm{before}}(w,v)-\delta(v)+\delta(w)\right]&amp;lt;/math&amp;gt;. [[Basics of shortest paths#Distances along shortest paths|This statement]] proves that the last expression is zero.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Cf. [[Successive shortest paths#Correctness|here]].&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
The asymptotic complexity and its proof are identical to the [[Successive shortest paths#Complexity|complexity considerations]] of the [[Successive shortest paths|successive shortest paths algorithm]]. Note that &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; may now be the asymptotic complexity of an algorithm that cannot handle negative arc weights.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Successive_shortest_paths&amp;diff=2798</id>
		<title>Successive shortest paths</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Successive_shortest_paths&amp;diff=2798"/>
		<updated>2015-02-20T14:37:39Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Abstract view */ Vereinheitlichung Seitenaufbau&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Min-cost flow problem]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# For a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;\delta f(v):=\sum_{w:(v,w)\in A}f(v,w)-\sum_{w:(w,v)\in A}f(w,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The '''imbalance''' of a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;I_f(v):=\delta f(v)-b(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The imbalance of a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''underestimating''' if &amp;lt;math&amp;gt;0\leq\delta f(v)\leq b(v)&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;0\geq\delta f(v)\geq b(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The '''total imbalance''' of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;\sum_{v\in V}|I_f(v)|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
# The capacity constraints are fulfilled, that is, &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
# There is no negative cycle in the [[Basic flow definitions#Residual network|residual network]] of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The imbalance of every node is underestimating.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
The total imbalance strictly decreases.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
The imbalances of all nodes are zero or there is no augmenting path from some node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(v)&amp;lt;0&amp;lt;/math&amp;gt; to any node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(w)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
Start with the zero flow.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obvious.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
# Choose some node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(s)&amp;lt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Find a shortest &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(t)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If there is none, terminate the algorithm.&lt;br /&gt;
# Increase the flow on all arcs of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; by the minimum of the following three values: &amp;lt;math&amp;gt;|I_f(s)|&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;I_f(t)&amp;gt;0&amp;lt;/math&amp;gt;, and the minimal [[Basic flow definitions#Residual network|residual capacity]] taken over all arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
Since cost values may be negative in the [[Basic flow definitions#Residual network|residual network]], step 2 requires an algorithm that copes with negative arc lengths. In particular, efficient algorithms such as [[Dijkstra|Dijkstra's]] are not an option. However, a [[Successive shortest paths with reduced costs|variant]] of the algorithm works on a nonnegative variation of the cost values, which allows efficient algorithms.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The variant follows from the fact that the amount by which the flow is increased in step 3 is strictly positive. The first and third points of the invariant result from the choice of this amount as the minimum of the imbalances of the end nodes and all residual capacities. Thus, it remains to show point 2 of the invariant.&lt;br /&gt;
&lt;br /&gt;
By induction hypothesis, there were no negative cycles immediately before the iteration. So, any negative cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; must have been created by the flow augmentation along &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;p_1,\ldots,p_k&amp;lt;/math&amp;gt; denote the [[Sets and sequences#Maximal and minimal sets|inclusion-maximal]] subpaths of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; whose [[Basic graph definitions#Paths|internal nodes]]  do not belong to &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. In other words, each &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; starts and ends on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; but does not share any further node with &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Now, for &amp;lt;math&amp;gt;i\in\{1,\ldots,k\}&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; denote&lt;br /&gt;
# the subpath of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; to the end node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;, if the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; appears on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; before its end node;&lt;br /&gt;
# the subpath of the [[Basic graph definitions#Transpose|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; to the end node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;, if the end node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; appears on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; before the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Further, let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be the cycle that results from &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; when each subpath &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; is replaced by the corresponding subpath &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; (in the first case) or of the [[Basic graph definitions#Transpose|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; (in the second case). In general, this cycle is extremely non-simple. It contains each arc of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as often as its opposite arc. Therefore, the total cost of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; ist zero. Now it suffices to show that the total cost of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is not smaller than the total cost of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. More specifically, for each &amp;lt;math&amp;gt;i\in\{1,\ldots,k\}&amp;lt;/math&amp;gt;, we will show that the cost of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; is not smaller than the cost of &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt;. Note that all arcs on all subpaths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; are in the residual network immediately before and immediately after the current iteration (with positive residual capacity, by definition). We apply the case distinction in the definition of &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; above.&lt;br /&gt;
# For a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; of the first type, the fact that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is a shortest path implies that &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; is a shortest path from its start node to its end node in the residual network immediately before the current iteration. Therefore, &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; is not shorter than &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; of the second type, let &amp;lt;math&amp;gt;p''&amp;lt;/math&amp;gt; denote the transpose of &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt;. In particular, &amp;lt;math&amp;gt;p''_i&amp;lt;/math&amp;gt; is a subpath of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p''_i&amp;lt;/math&amp;gt; form a cycle, and that this cycle was augmenting immediately before the current iteration. By induction hypothesis, this cycle is not negative, &amp;lt;math&amp;gt;c(p_i)+c(p''_i)\geq 0&amp;lt;/math&amp;gt;. The claim now follows from &amp;lt;math&amp;gt;c(p'_i)=-c(p''_i)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
The proof of the induction step shows that the invariant is fulfilled on termination. If no path is found, the instance is obviously infeasible. On the other hand, if all imbalances are removed, the resulting flow is feasible. Due to the second point of the invariant, it is also minimum (cf. [[Negative cycle-canceling#Correctness|here]]).&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(B\cdot T)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;B=\sum_{v\in V}|b(v)|&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the asymptotic complexity of the shortest-path algorithm.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, the number of iterations is in &amp;lt;math&amp;gt;\mathcal{O}(B)&amp;lt;/math&amp;gt;. The complexity of an iteration is dominated by the shortest-path computation.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Successive_shortest_paths&amp;diff=2797</id>
		<title>Successive shortest paths</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Successive_shortest_paths&amp;diff=2797"/>
		<updated>2015-02-20T14:06:39Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction step */ Hier muss Zykel C gemeint sein, damit Beweis Sinn ergibt&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# For a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;\delta f(v):=\sum_{w:(v,w)\in A}f(v,w)-\sum_{w:(w,v)\in A}f(w,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The '''imbalance''' of a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;I_f(v):=\delta f(v)-b(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The imbalance of a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''underestimating''' if &amp;lt;math&amp;gt;0\leq\delta f(v)\leq b(v)&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;0\geq\delta f(v)\geq b(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The '''total imbalance''' of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as &amp;lt;math&amp;gt;\sum_{v\in V}|I_f(v)|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
# The capacity constraints are fulfilled, that is, &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
# There is no negative cycle in the [[Basic flow definitions#Residual network|residual network]] of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The imbalance of every node is underestimating.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
The total imbalance strictly decreases.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
The imbalances of all nodes are zero or there is no augmenting path from some node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(v)&amp;lt;0&amp;lt;/math&amp;gt; to any node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(w)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
Start with the zero flow.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obvious.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
# Choose some node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(s)&amp;lt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Find a shortest &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;I_f(t)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If there is none, terminate the algorithm.&lt;br /&gt;
# Increase the flow on all arcs of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; by the minimum of the following three values: &amp;lt;math&amp;gt;|I_f(s)|&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;I_f(t)&amp;gt;0&amp;lt;/math&amp;gt;, and the minimal [[Basic flow definitions#Residual network|residual capacity]] taken over all arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
Since cost values may be negative in the [[Basic flow definitions#Residual network|residual network]], step 2 requires an algorithm that copes with negative arc lengths. In particular, efficient algorithms such as [[Dijkstra|Dijkstra's]] are not an option. However, a [[Successive shortest paths with reduced costs|variant]] of the algorithm works on a nonnegative variation of the cost values, which allows efficient algorithms.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The variant follows from the fact that the amount by which the flow is increased in step 3 is strictly positive. The first and third points of the invariant result from the choice of this amount as the minimum of the imbalances of the end nodes and all residual capacities. Thus, it remains to show point 2 of the invariant.&lt;br /&gt;
&lt;br /&gt;
By induction hypothesis, there were no negative cycles immediately before the iteration. So, any negative cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; must have been created by the flow augmentation along &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;p_1,\ldots,p_k&amp;lt;/math&amp;gt; denote the [[Sets and sequences#Maximal and minimal sets|inclusion-maximal]] subpaths of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; whose [[Basic graph definitions#Paths|internal nodes]]  do not belong to &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. In other words, each &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; starts and ends on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; but does not share any further node with &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Now, for &amp;lt;math&amp;gt;i\in\{1,\ldots,k\}&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; denote&lt;br /&gt;
# the subpath of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; to the end node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;, if the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; appears on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; before its end node;&lt;br /&gt;
# the subpath of the [[Basic graph definitions#Transpose|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; to the end node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;, if the end node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; appears on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; before the start node of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Further, let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be the cycle that results from &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; when each subpath &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; is replaced by the corresponding subpath &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; (in the first case) or of the [[Basic graph definitions#Transpose|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; (in the second case). In general, this cycle is extremely non-simple. It contains each arc of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as often as its opposite arc. Therefore, the total cost of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; ist zero. Now it suffices to show that the total cost of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is not smaller than the total cost of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. More specifically, for each &amp;lt;math&amp;gt;i\in\{1,\ldots,k\}&amp;lt;/math&amp;gt;, we will show that the cost of &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; is not smaller than the cost of &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt;. Note that all arcs on all subpaths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; are in the residual network immediately before and immediately after the current iteration (with positive residual capacity, by definition). We apply the case distinction in the definition of &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; above.&lt;br /&gt;
# For a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; of the first type, the fact that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is a shortest path implies that &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; is a shortest path from its start node to its end node in the residual network immediately before the current iteration. Therefore, &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt; is not shorter than &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; of the second type, let &amp;lt;math&amp;gt;p''&amp;lt;/math&amp;gt; denote the transpose of &amp;lt;math&amp;gt;p'_i&amp;lt;/math&amp;gt;. In particular, &amp;lt;math&amp;gt;p''_i&amp;lt;/math&amp;gt; is a subpath of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p''_i&amp;lt;/math&amp;gt; form a cycle, and that this cycle was augmenting immediately before the current iteration. By induction hypothesis, this cycle is not negative, &amp;lt;math&amp;gt;c(p_i)+c(p''_i)\geq 0&amp;lt;/math&amp;gt;. The claim now follows from &amp;lt;math&amp;gt;c(p'_i)=-c(p''_i)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
The proof of the induction step shows that the invariant is fulfilled on termination. If no path is found, the instance is obviously infeasible. On the other hand, if all imbalances are removed, the resulting flow is feasible. Due to the second point of the invariant, it is also minimum (cf. [[Negative cycle-canceling#Correctness|here]]).&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(B\cdot T)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;B=\sum_{v\in V}|b(v)|&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the asymptotic complexity of the shortest-path algorithm.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, the number of iterations is in &amp;lt;math&amp;gt;\mathcal{O}(B)&amp;lt;/math&amp;gt;. The complexity of an iteration is dominated by the shortest-path computation.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2796</id>
		<title>Preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2796"/>
		<updated>2015-02-17T13:12:23Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction step */ intuitivere Benennung&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Max-Flow Problems#Standard version|max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
loop.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A nonnegative integral value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node &amp;lt;math&amp;gt;v\in V\setminus\{t\}&amp;lt;/math&amp;gt; has a '''current arc''', which may be implemented as an iterator on the list of outgoing residual arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The [[Basic flow definitions#Preflow|excess]] &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; of a node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; with respect to the current [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# A (dynamically changing) [[Sets and sequences|set]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of nodes.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; . If all upper bounds are integral, all &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral, too.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\} &amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;e_f(v)\geq 0&amp;lt;/math&amp;gt;. In other words, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# The node labels &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; form a [[Basic flow definitions#Valid distance labeling|valid distance labeling]], and it is &amp;lt;math&amp;gt;d(s)=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The currently [[Basic flow definitions#Preflow|active nodes]] are stored in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
In each iteration, one of the following three actions will take place:&lt;br /&gt;
# The label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of at least one node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; is increased.&lt;br /&gt;
# A saturating push is performed.&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;D:=\sum_{v\in V\setminus\{s,t\}\atop e_f(v)&amp;gt;0}d(v)&amp;lt;/math&amp;gt; decreases.&lt;br /&gt;
No label &amp;lt;math&amp;gt;d(\cdot)&amp;lt;/math&amp;gt; is ever decreased.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
&amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;f(a):=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;(s,v)\in A&amp;lt;/math&amp;gt;, overwrite this value by &amp;lt;math&amp;gt;f(a):=u(a)&amp;lt;/math&amp;gt; and put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Compute a [[Basic flow definitions#Valid distance labeling|valid distance labeling]] &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;, for example, the true distances from all nodes to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;d(s):=n&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the first arc in the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For the [[Basic graph definitions#Subgraphs|subgraph induced]] by &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt;, the arguments in the [[Ahuja-Orlin#Correctness|correctness proof]] for the [[Ahuja-Orlin]] algorithm prove that the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-labels form a valid distance labeling here as well. For &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, nothing is to show because all outgoing arcs are saturated.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Choose an [[Basic flow definitions#Preflow|active node]] &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and not [[Basic flow definitions#Valid distance labeling|admissible]] either, move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is ''not'' void now but an (admissible) outgoing arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;, say:&lt;br /&gt;
## If &amp;lt;math&amp;gt;w\neq s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_f(w)=0&amp;lt;/math&amp;gt;, insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase the flow over &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by the minimum of &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; and the residual capacity of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;e_f(w)&amp;lt;/math&amp;gt; by that value and decrease &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; by the same value.&lt;br /&gt;
## If &amp;lt;math&amp;gt;e_f(v)=0&amp;lt;/math&amp;gt; now, extract &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;d_\min&amp;lt;/math&amp;gt; denote the minimal label &amp;lt;math&amp;gt;d(w)&amp;lt;/math&amp;gt; of any arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the residual network.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;d(v):=d_\min+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the beginning of the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
The preflow-push algorithm is also known as the '''push-relabel''' algorithm. The ''push'' operation is step 3; the ''relabel'' operation is step 4.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Points 1, 2, and 4 of the invariant and &amp;lt;math&amp;gt;d(s)=n&amp;lt;/math&amp;gt; are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; ensures point 3 of the invariant.&lt;br /&gt;
&lt;br /&gt;
To prove the variant, consider a step in which neither any &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not saturated by that. Potentially, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; becomes active. However, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that &amp;lt;math&amp;gt;d(w)=d(v)-1&amp;lt;/math&amp;gt; for an admissible arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It remains to show termination; this is proved by the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show that the total number of relabel operations (step 4 of the main loop) is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with positive flow on all arcs. The [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is [[Basic flow definitions#Flow-augmenting paths and saturated arcs|augmenting]]. Due to the validity of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; (induction hypothesis), &amp;lt;math&amp;gt;d(v)-d(s)=d(v)-n&amp;lt;/math&amp;gt; cannot be larger than the number of arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, which is not larger than &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, no node label can be larger than &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;. Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.&lt;br /&gt;
&lt;br /&gt;
From this bound, we may immediately conclude that the current arc of a node is reset &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt; times, so the total number of forward steps of the current arcs of all nodes is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The argument in the [[Ahuja-Orlin#Complexity|complexity analysis]] of the [[Ahuja-Orlin]] algorithm to prove that the total number of ''saturating'' push operations is in &amp;lt;math&amp;gt;\mathcal{O}(nm)&amp;lt;/math&amp;gt;, applies here as well.&lt;br /&gt;
&lt;br /&gt;
Finally, we consider the ''non-saturating'' push operations. First note that &amp;lt;math&amp;gt;D\geq 0&amp;lt;/math&amp;gt; before and after each iteration. The value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; increases by less than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total over all relabel operations. On the other hand, a saturating push operation may increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by at most &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt; (namely, in the case that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; was not active immediately before the push). In summary, the total sum of all values by which &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased throughout the algorithm is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;. Due to the variant, the value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased by at least one in each non-saturating push operation. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Heuristic speedup techniques ==&lt;br /&gt;
&lt;br /&gt;
# After &amp;lt;math&amp;gt;\Omega(n)&amp;lt;/math&amp;gt; iterations of the main loop, the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-values are recomputed analogously to the induction basis: as the current distance of each node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.&lt;br /&gt;
# The main loop may be decomposed into two phases: First, as much flow as possible is sent into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;; second, all surplus flow that cannot reach &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is sent back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. The first phase may be finished once there is no more path in the residual network from any active node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. A sufficient and easy-to-check condition for that is &amp;lt;math&amp;gt;d(v)\geq n&amp;lt;/math&amp;gt; for all active nodes &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. All nodes from which &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Three_indians%27_algorithm&amp;diff=2795</id>
		<title>Three indians' algorithm</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Three_indians%27_algorithm&amp;diff=2795"/>
		<updated>2015-02-16T13:30:38Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Blocking flow]].&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop.&lt;br /&gt;
&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
The current flow is feasible.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
The number of nodes strictly decreases.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
There is no more [[Basic graph definitions#Paths|ordinary &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path]] in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
The flow is initialized to be feasible, for example, the zero flow.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obvious.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
Choose the node &amp;lt;math&amp;gt;v_0&amp;lt;/math&amp;gt; through which the minimum amount of flow may go, and propagate this amount from &amp;lt;math&amp;gt;v_0&amp;lt;/math&amp;gt; forward to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; and backward to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementation:'''&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;T(v)&amp;lt;/math&amp;gt; denote the '''throughput''' of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, which is defined by &amp;lt;math&amp;gt;T(v):=\min\left\{\sum_{w:(v,w)\in A}u(v,w),\sum_{w:(w,v)\in A}u(w,v)\right\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Remove all nodes with zero throughput and all arcs incident to at least one of these nodes.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;v_0\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be a node with minimum throughput &amp;lt;math&amp;gt;T(v_0)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;F(v_0):=T(v_0)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;F(v):=0&amp;lt;/math&amp;gt; for all nodes &amp;lt;math&amp;gt;v\in V\setminus\{s,t,v_0\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Run a modified [[Breadth-first search|BFS]] from &amp;lt;math&amp;gt;v_0&amp;lt;/math&amp;gt;, where for every processed arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt;:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;\Delta:=\min\{u(v,w),F(v)\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Set the flow over &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;F(w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Decrease &amp;lt;math&amp;gt;F(v)&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;T(v)&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;u(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\Delta&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If &amp;lt;math&amp;gt;u(v,w)=0&amp;lt;/math&amp;gt;, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If &amp;lt;math&amp;gt;F(v)=0&amp;lt;/math&amp;gt;, finish this iteration.&lt;br /&gt;
# Run the same modified [[Breadth-first search|BFS]] from &amp;lt;math&amp;gt;v_0&amp;lt;/math&amp;gt; on  the [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; (all removals apply to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Consider step 5 (step 6 is analogous). The specific choice of &amp;lt;matH&amp;gt;v_0&amp;lt;/math&amp;gt; ensures &amp;lt;math&amp;gt;F(v)\leq T(v_0)\leq T(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; at any time. Therefore, all flow arrived at &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; can be moved forward along the arcs leaving &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. In other words, when &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is finished, it is &amp;lt;math&amp;gt;F(v)=0&amp;lt;/math&amp;gt;. Since &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is an [[Basic graph definitions#Cycles|&amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-graph]], the result is a feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow, and the flow value has increased by the initial value of &amp;lt;math&amp;gt;T(v_0)&amp;lt;/math&amp;gt;. In particular, it is &amp;lt;math&amp;gt;T(v_0)=0&amp;lt;/math&amp;gt; at the end, so at least &amp;lt;math&amp;gt;v_0&amp;lt;/math&amp;gt; will be removed in this iteration.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
When a node is removed, either all of its outgoing arcs or all of its ingoing arcs are saturated. Therefore, an arc is only removed if this arc itself or all immediate predecessors or all immediate successors are saturated. In particular, an arc is only removed if it is not on any flow-augmenting path anymore. Therefore, when the break condition is fulfilled, the flow is blocking. Termination follows from the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Due to the variant, the number of iterations is linear in &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;. When an arc is saturated, it is removed in step 5.5 (resp., 6.5), so the total number of saturating increases of flow values of arcs over all iterations of the main loop is linear in the number of arcs, which is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. In each execution of step 5 (resp., step 6), the flow on at most one outgoing (resp., incoming) arc of each node is increased without saturation, so the number of ''non''-saturating flow value settings is linear in the number of nodes in each iteration.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The algorithm is named after three indian researchers, V. M. Malhotra, M. Pramodh Kumar, and S. N. Mahashwari.&lt;br /&gt;
# Of course, the nodes and arcs need not really be removed from the graph. However, &amp;quot;removed&amp;quot; nodes and arcs must be hidden from the algorithm to ensure the asymptotic complexity; a Boolean label &amp;quot;is removed&amp;quot; does not suffice for that.&lt;br /&gt;
# This application of [[Breadth-first search|BFS]] is an example for one of the remarks on [[Graph traversal#Remarks|graph traversal]]: It is reasonable to implement graph-traversal algorithms as iterators. In fact, then the modification may be simply added to the loop that runs the iterator.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Negative_cycle-canceling&amp;diff=2793</id>
		<title>Negative cycle-canceling</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Negative_cycle-canceling&amp;diff=2793"/>
		<updated>2015-02-05T15:18:29Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Min-cost flow problem]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
# The flow is [[Basic flow definitions#Feasible flow|feasible]].&lt;br /&gt;
#  If all upper bounds are integral, the flow is integral as well.&lt;br /&gt;
&lt;br /&gt;
'''Variant:''' The cost of the flow decreases.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:''' There is no more [[Basics of shortest paths#Path lengths and distances|negative cycle]] in the residual network.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Start with an arbitrary feasible flow.&lt;br /&gt;
&lt;br /&gt;
'''Implementation:'''&lt;br /&gt;
The problem to find a feasible flow is reduced to a [[Max-Flow Problems|max-flow problem]] as follows:&lt;br /&gt;
# Insert new vertices, &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each original node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;b[v]&amp;gt;0&amp;lt;/math&amp;gt;: Insert an arc &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt; with capacity &amp;lt;math&amp;gt;b[v]&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each original node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;b[v]&amp;lt;0&amp;lt;/math&amp;gt;: Insert an arc &amp;lt;math&amp;gt;(v,t)&amp;lt;/math&amp;gt; with capacity &amp;lt;math&amp;gt;-b[v]&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Determine a [[Max-Flow Problems|maximum flow]] from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the extended graph (cost factors and balance values are disregarded).&lt;br /&gt;
# If all arcs &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt; are [[Basic flow definitions#Flow-augmenting paths and saturated arcs|saturated]], return the restriction of this flow to the original arcs.&lt;br /&gt;
# Otherwise, the original [[Min-cost flow problem|min-cost flow]] instance is infeasible.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If the arcs leaving &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; (or, equivalently, the arcs entering &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;) are saturated, the flow balances at all original nodes are obviously fulfilled in the original [[Min-cost flow problem|min-cost flow]] instance. On the other hand, if a feasible flow exists at all in the original [[Min-cost flow problem|min-cost flow]] instance, its extension to the inserted arcs yields a flow that saturates all arcs leaving &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. Therefore, if the ''maximum'' flow in the extended flow network does not saturate all of these arcs, the original instance is infeasible.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Find a [[Basics of shortest paths#Path lengths and distances|cycle of negative cost]] in the [[Basic flow definitions#Residual network|residual network]].&lt;br /&gt;
# [[Basic flow definitions#Augmenting along a path|Augment]] the flow along this cycle up to saturation.&lt;br /&gt;
&lt;br /&gt;
'''Implementation of step 1:'''&lt;br /&gt;
# Run an [[All pairs shortest paths|all-pairs shortest-paths]] algorithm on the [[Basic flow definitions#Residual network|residual network]] &amp;lt;math&amp;gt;(G_f,u_f)&amp;lt;/math&amp;gt;, where for each arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt;, the length of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;c(v,w)&amp;lt;/math&amp;gt; in case &amp;lt;math&amp;gt;(v,w)\in A_f&amp;lt;/math&amp;gt;, and the length of  &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;-c(v,w)&amp;lt;/math&amp;gt; in case &amp;lt;math&amp;gt;(w,v)\in A_f&amp;lt;/math&amp;gt;. Let the algorithm [[Basics of shortest paths#Constructing a shortest-paths arborescence or a negative cycle|construct an arborescence or a negative cycle]].&lt;br /&gt;
# If the distance &amp;lt;math&amp;gt;v\rightarrow v&amp;lt;/math&amp;gt; is 0 for all &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, the break condition applies.&lt;br /&gt;
# Otherwise (that is, the distances &amp;lt;math&amp;gt;v\rightarrow v&amp;lt;/math&amp;gt; of some nodes &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; are negative): Reconstruct one negative cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The invariant and the variant are obviously fulfilled.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
In the following, arithmetic operations and comparisons of flows are arc-wise. For a [[Basic graph definitions#Cycles|generalized cycle]] &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\varepsilon&amp;gt;0&amp;lt;/math&amp;gt;, adding &amp;lt;math&amp;gt;\varepsilon\cdot C&amp;lt;/math&amp;gt; to a flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; means that &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is [[Basic flow definitions#Augmenting along a path|augmented]] along &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
First we will show a general fact: For two feasible flows, &amp;lt;math&amp;gt;f_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f_2&amp;lt;/math&amp;gt;, there are [[basic graph definitions#Cycles|generalized cycles]] &amp;lt;math&amp;gt;C_1,\ldots,C_k&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\varepsilon_1,\ldots,\varepsilon_k&amp;gt;0&amp;lt;/math&amp;gt; such that:&lt;br /&gt;
# '''Decomposition''' of &amp;lt;math&amp;gt;f_2-f_1&amp;lt;/math&amp;gt;: It is &amp;lt;math&amp;gt;f_2=f_1+\varepsilon_1\cdot C_1+\cdots+\varepsilon_k\cdot C_k&amp;lt;/math&amp;gt;.&lt;br /&gt;
# '''Consistency:''' For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;i,j\in\{1,\ldots,k\}&amp;lt;/math&amp;gt;: If &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; belongs to &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt;, then &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is a forward arc on both cycles, or &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is a backward arc in both cycles.&lt;br /&gt;
&lt;br /&gt;
To prove this general fact, we apply an induction on the number &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; of arcs on which &amp;lt;math&amp;gt;f_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f_2&amp;lt;/math&amp;gt; differ. For &amp;lt;math&amp;gt;d=0&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;f_1=f_2&amp;lt;/math&amp;gt;, so the empty set of cycles (&amp;lt;math&amp;gt;k=0&amp;lt;/math&amp;gt;) describes the difference between &amp;lt;math&amp;gt;f_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
So suppose &amp;lt;math&amp;gt;d&amp;gt;0&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;(v_1,v_2)&amp;lt;/math&amp;gt; be an arc on which &amp;lt;math&amp;gt;f_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f_2&amp;lt;/math&amp;gt; differ, say &amp;lt;math&amp;gt;f_1(v_1,v_2)&amp;lt;f_2(v_1,v_2)&amp;lt;/math&amp;gt;. Then there is either an arc &amp;lt;math&amp;gt;(v_2,v_3)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;f_1(v_2,v_3)&amp;lt;f_2(v_2,v_3)&amp;lt;/math&amp;gt; or an arc &amp;lt;math&amp;gt;(v_3,v_2)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;f_1(v_3,v_2)&amp;gt;f_2(v_3,v_2)&amp;lt;/math&amp;gt;. This argument may be continued, so we obtain a sequence &amp;lt;math&amp;gt;v_1,v_2,v_3,v_4,\ldots&amp;lt;/math&amp;gt; such that for all &amp;lt;math&amp;gt;i=1,2,3,\ldots&amp;lt;/math&amp;gt;, there is &amp;lt;math&amp;gt;(v_i,v_{i+1})&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;f_1(v_i,v_{i+1})&amp;lt;f_2(v_i,v_{i+1})&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;(v_{i+1},v_i)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;f_1(v_{i+1},v_i)&amp;lt;f_2(v_{i+1},v_i)&amp;lt;/math&amp;gt;. Since the number of nodes is finite, there must be &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v_i=v_j&amp;lt;/math&amp;gt;. Therefore,  a generalized cycle &amp;lt;math&amp;gt;C_1&amp;lt;/math&amp;gt; is closed such that &amp;lt;math&amp;gt;f_1(a)&amp;lt;f_2(a)\leq u(a)&amp;lt;/math&amp;gt; on each forward arc and &amp;lt;math&amp;gt;f_1(a)&amp;gt;f_2(a)\geq 0&amp;lt;/math&amp;gt; on each backward arc. In particular, there is &amp;lt;math&amp;gt;\varepsilon_1&amp;gt;0&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;f_1+\varepsilon_1\cdot C_1&amp;lt;/math&amp;gt; is feasible. If &amp;lt;math&amp;gt;\varepsilon_1&amp;lt;/math&amp;gt; is chosen maximal, &amp;lt;math&amp;gt;f_1+\varepsilon_1\cdot C_1&amp;lt;/math&amp;gt; agrees one at least one more arc with &amp;lt;math&amp;gt;f_2&amp;lt;/math&amp;gt; than &amp;lt;math&amp;gt;f_1&amp;lt;/math&amp;gt;. Now the induction hypothesis proves the general fact.&lt;br /&gt;
&lt;br /&gt;
Finally, we are in a position to prove correctness of the algorithm. For  that, we have to show that a feasible flow is minimum if it admits no negative cycle. So assume a feasible flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is ''not'' minimum. Then there is a feasible flow &amp;lt;math&amp;gt;\tilde{f}&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;c(\tilde{f})&amp;lt;c(f)&amp;lt;/math&amp;gt;. There are &amp;lt;math&amp;gt;C_1,\ldots,C_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\varepsilon_1,\ldots,\varepsilon_k&amp;lt;/math&amp;gt; as described above. Since &amp;lt;math&amp;gt;c(\tilde{f})&amp;lt;c(f)&amp;lt;/math&amp;gt;, at least one of the cycles must be a negative one,say &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt;. Since the cycles are consistent, they may be permuted in the decomposition, so &amp;lt;math&amp;gt;f+\varepsilon_i\cdot C_i&amp;lt;/math&amp;gt; is feasible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
If all upper bounds are integral, the asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(T\cdot C\cdot U)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is the asymptotic complexity of the [[All pairs shortest paths|all-pairs shortest-paths problem]], &amp;lt;math&amp;gt;C=\sum_{a\in A}|c(a)|&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;U=\max\{u(a)|a\in A\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The initial flow has a total cost of at most &amp;lt;math&amp;gt;C\cdot U&amp;lt;/math&amp;gt;, and the min-cost flow has a total cost of at least &amp;lt;math&amp;gt;-C\cdot U&amp;lt;/math&amp;gt;. Therefore, the number of iterations is in &amp;lt;math&amp;gt;\mathcal{O}(C\cdot U)&amp;lt;/math&amp;gt;. The complexity of an iteration is dominated by the all-pairs shortest-paths algorithm.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2792</id>
		<title>Preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2792"/>
		<updated>2015-02-04T18:03:44Z</updated>

		<summary type="html">&lt;p&gt;BB91: Undo revision 2789 by BB91 (talk) wird in vielen anderen Artikeln als O(n^2) benötigt&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Max-Flow Problems#Standard version|max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
loop.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A nonnegative integral value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node &amp;lt;math&amp;gt;v\in V\setminus\{t\}&amp;lt;/math&amp;gt; has a '''current arc''', which may be implemented as an iterator on the list of outgoing residual arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The [[Basic flow definitions#Preflow|excess]] &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; of a node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; with respect to the current [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# A (dynamically changing) [[Sets and sequences|set]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of nodes.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; . If all upper bounds are integral, all &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral, too.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\} &amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;e_f(v)\geq 0&amp;lt;/math&amp;gt;. In other words, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# The node labels &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; form a [[Basic flow definitions#Valid distance labeling|valid distance labeling]], and it is &amp;lt;math&amp;gt;d(s)=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The currently [[Basic flow definitions#Preflow|active nodes]] are stored in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
In each iteration, one of the following three actions will take place:&lt;br /&gt;
# The label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of at least one node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; is increased.&lt;br /&gt;
# A saturating push is performed.&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;D:=\sum_{v\in V\setminus\{s,t\}\atop e_f(v)&amp;gt;0}d(v)&amp;lt;/math&amp;gt; decreases.&lt;br /&gt;
No label &amp;lt;math&amp;gt;d(\cdot)&amp;lt;/math&amp;gt; is ever decreased.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
&amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;f(a):=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;(s,v)\in A&amp;lt;/math&amp;gt;, overwrite this value by &amp;lt;math&amp;gt;f(a):=u(a)&amp;lt;/math&amp;gt; and put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Compute a [[Basic flow definitions#Valid distance labeling|valid distance labeling]] &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;, for example, the true distances from all nodes to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;d(s):=n&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the first arc in the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For the [[Basic graph definitions#Subgraphs|subgraph induced]] by &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt;, the arguments in the [[Ahuja-Orlin#Correctness|correctness proof]] for the [[Ahuja-Orlin]] algorithm prove that the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-labels form a valid distance labeling here as well. For &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, nothing is to show because all outgoing arcs are saturated.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Choose an [[Basic flow definitions#Preflow|active node]] &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and not [[Basic flow definitions#Valid distance labeling|admissible]] either, move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is ''not'' void now but an (admissible) outgoing arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;, say:&lt;br /&gt;
## If &amp;lt;math&amp;gt;w\neq s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_f(w)=0&amp;lt;/math&amp;gt;, insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase the flow over &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by the minimum of &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; and the residual capacity of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;e_f(w)&amp;lt;/math&amp;gt; by that value and decrease &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; by the same value.&lt;br /&gt;
## If &amp;lt;math&amp;gt;e_f(v)=0&amp;lt;/math&amp;gt; now, extract &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;d_\max&amp;lt;/math&amp;gt; denote the minimal label &amp;lt;math&amp;gt;d(w)&amp;lt;/math&amp;gt; of any arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the residual network.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;d(v):=d_\max+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the beginning of the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
The preflow-push algorithm is also known as the '''push-relabel''' algorithm. The ''push'' operation is step 3; the ''relabel'' operation is step 4.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Points 1, 2, and 4 of the invariant and &amp;lt;math&amp;gt;d(s)=n&amp;lt;/math&amp;gt; are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; ensures point 3 of the invariant.&lt;br /&gt;
&lt;br /&gt;
To prove the variant, consider a step in which neither any &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not saturated by that. Potentially, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; becomes active. However, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that &amp;lt;math&amp;gt;d(w)=d(v)-1&amp;lt;/math&amp;gt; for an admissible arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It remains to show termination; this is proved by the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show that the total number of relabel operations (step 4 of the main loop) is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with positive flow on all arcs. The [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is [[Basic flow definitions#Flow-augmenting paths and saturated arcs|augmenting]]. Due to the validity of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; (induction hypothesis), &amp;lt;math&amp;gt;d(v)-d(s)=d(v)-n&amp;lt;/math&amp;gt; cannot be larger than the number of arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, which is not larger than &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, no node label can be larger than &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;. Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.&lt;br /&gt;
&lt;br /&gt;
From this bound, we may immediately conclude that the current arc of a node is reset &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt; times, so the total number of forward steps of the current arcs of all nodes is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The argument in the [[Ahuja-Orlin#Complexity|complexity analysis]] of the [[Ahuja-Orlin]] algorithm to prove that the total number of ''saturating'' push operations is in &amp;lt;math&amp;gt;\mathcal{O}(nm)&amp;lt;/math&amp;gt;, applies here as well.&lt;br /&gt;
&lt;br /&gt;
Finally, we consider the ''non-saturating'' push operations. First note that &amp;lt;math&amp;gt;D\geq 0&amp;lt;/math&amp;gt; before and after each iteration. The value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; increases by less than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total over all relabel operations. On the other hand, a saturating push operation may increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by at most &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt; (namely, in the case that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; was not active immediately before the push). In summary, the total sum of all values by which &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased throughout the algorithm is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;. Due to the variant, the value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased by at least one in each non-saturating push operation. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Heuristic speedup techniques ==&lt;br /&gt;
&lt;br /&gt;
# After &amp;lt;math&amp;gt;\Omega(n)&amp;lt;/math&amp;gt; iterations of the main loop, the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-values are recomputed analogously to the induction basis: as the current distance of each node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.&lt;br /&gt;
# The main loop may be decomposed into two phases: First, as much flow as possible is sent into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;; second, all surplus flow that cannot reach &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is sent back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. The first phase may be finished once there is no more path in the residual network from any active node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. A sufficient and easy-to-check condition for that is &amp;lt;math&amp;gt;d(v)\geq n&amp;lt;/math&amp;gt; for all active nodes &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. All nodes from which &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=FIFO_preflow-push&amp;diff=2791</id>
		<title>FIFO preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=FIFO_preflow-push&amp;diff=2791"/>
		<updated>2015-02-04T17:56:25Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Complexity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
This is a specialization of the [[Preflow-push|generic preflow-push algorithm]]:&lt;br /&gt;
# The set of all [[Basic flow definitions#Preflow|active nodes]] is stored in a [[Sets and sequences#Stacks and queues|FIFO queue]] &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Always choose the first node in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; (recall from the generic preflow-push that this node is not extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; as long as it is active).&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^3)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The [[Preflow-push#Complexity|complexity considerations]] for the [[Preflow-push|generic preflow-push algorithm]] yield &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt; relabel operations and forward steps of current arcs, and &amp;lt;math&amp;gt;\mathcal{O}(n\!\cdot\!m)\subseteq\mathcal{O}(n^3)&amp;lt;/math&amp;gt; saturating push operations, where &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;. There it was also shown that the total number of changes of outgoing arcs is in &amp;lt;math&amp;gt;\mathcal{O}(n^3)&amp;lt;/math&amp;gt;. Hence, it remains to show that the total number of non-saturating push operations is in &amp;lt;math&amp;gt;\mathcal{O}(n^3)&amp;lt;/math&amp;gt; as well.&lt;br /&gt;
&lt;br /&gt;
Conceptually, we may partition the iterations of the main loop into ''phases''. The first phase commences with the very first iteration. A new phase commences as soon as all nodes that were in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; at the beginning of the last phase, have been extracted once from &amp;lt;matH&amp;gt;Q&amp;lt;/math&amp;gt;. Before and after each iteration, let &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; denote the maximum label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of any active node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;. In particular, it is always &amp;lt;math&amp;gt;0\leq D&amp;lt;2n&amp;lt;/math&amp;gt;. Clearly, only relabel operations can increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt;, and the sum of all increases of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt;, taken over all relabel operations, cannot increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by more than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total.&lt;br /&gt;
&lt;br /&gt;
This observation immediately implies that the number of phases in which at least one relabeling operation takes place, is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. On the other hand, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased in every phase without relabel operation, because in this case, all excess is pushed from each active node to a node with smaller &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-label. Due to the bound &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt; on all increases of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt;, the number of ''de''creases of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; and, hence, the number of phases without relabel operations is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt; as well. The claim now follows from the observation that, in each phase, at most one non-saturating push is performed with each node because a non-saturating push makes a node inactive.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2790</id>
		<title>Preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2790"/>
		<updated>2015-02-04T17:34:04Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Abstract view */ current arc muss im Residualgraph sein&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Max-Flow Problems#Standard version|max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
loop.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A nonnegative integral value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node &amp;lt;math&amp;gt;v\in V\setminus\{t\}&amp;lt;/math&amp;gt; has a '''current arc''', which may be implemented as an iterator on the list of outgoing residual arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The [[Basic flow definitions#Preflow|excess]] &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; of a node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; with respect to the current [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# A (dynamically changing) [[Sets and sequences|set]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of nodes.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; . If all upper bounds are integral, all &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral, too.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\} &amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;e_f(v)\geq 0&amp;lt;/math&amp;gt;. In other words, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# The node labels &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; form a [[Basic flow definitions#Valid distance labeling|valid distance labeling]], and it is &amp;lt;math&amp;gt;d(s)=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The currently [[Basic flow definitions#Preflow|active nodes]] are stored in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
In each iteration, one of the following three actions will take place:&lt;br /&gt;
# The label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of at least one node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; is increased.&lt;br /&gt;
# A saturating push is performed.&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;D:=\sum_{v\in V\setminus\{s,t\}\atop e_f(v)&amp;gt;0}d(v)&amp;lt;/math&amp;gt; decreases.&lt;br /&gt;
No label &amp;lt;math&amp;gt;d(\cdot)&amp;lt;/math&amp;gt; is ever decreased.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
&amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;f(a):=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;(s,v)\in A&amp;lt;/math&amp;gt;, overwrite this value by &amp;lt;math&amp;gt;f(a):=u(a)&amp;lt;/math&amp;gt; and put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Compute a [[Basic flow definitions#Valid distance labeling|valid distance labeling]] &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;, for example, the true distances from all nodes to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;d(s):=n&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the first arc in the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For the [[Basic graph definitions#Subgraphs|subgraph induced]] by &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt;, the arguments in the [[Ahuja-Orlin#Correctness|correctness proof]] for the [[Ahuja-Orlin]] algorithm prove that the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-labels form a valid distance labeling here as well. For &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, nothing is to show because all outgoing arcs are saturated.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Choose an [[Basic flow definitions#Preflow|active node]] &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and not [[Basic flow definitions#Valid distance labeling|admissible]] either, move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is ''not'' void now but an (admissible) outgoing arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;, say:&lt;br /&gt;
## If &amp;lt;math&amp;gt;w\neq s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_f(w)=0&amp;lt;/math&amp;gt;, insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase the flow over &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by the minimum of &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; and the residual capacity of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;e_f(w)&amp;lt;/math&amp;gt; by that value and decrease &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; by the same value.&lt;br /&gt;
## If &amp;lt;math&amp;gt;e_f(v)=0&amp;lt;/math&amp;gt; now, extract &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;d_\max&amp;lt;/math&amp;gt; denote the minimal label &amp;lt;math&amp;gt;d(w)&amp;lt;/math&amp;gt; of any arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the residual network.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;d(v):=d_\max+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the beginning of the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
The preflow-push algorithm is also known as the '''push-relabel''' algorithm. The ''push'' operation is step 3; the ''relabel'' operation is step 4.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Points 1, 2, and 4 of the invariant and &amp;lt;math&amp;gt;d(s)=n&amp;lt;/math&amp;gt; are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; ensures point 3 of the invariant.&lt;br /&gt;
&lt;br /&gt;
To prove the variant, consider a step in which neither any &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not saturated by that. Potentially, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; becomes active. However, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that &amp;lt;math&amp;gt;d(w)=d(v)-1&amp;lt;/math&amp;gt; for an admissible arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It remains to show termination; this is proved by the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show that the total number of relabel operations (step 4 of the main loop) is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with positive flow on all arcs. The [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is [[Basic flow definitions#Flow-augmenting paths and saturated arcs|augmenting]]. Due to the validity of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; (induction hypothesis), &amp;lt;math&amp;gt;d(v)-d(s)=d(v)-n&amp;lt;/math&amp;gt; cannot be larger than the number of arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, which is not larger than &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, no node label can be larger than &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;. Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.&lt;br /&gt;
&lt;br /&gt;
From this bound, we may immediately conclude that the current arc of a node is reset &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt; times, so the total number of forward steps of the current arcs of all nodes is in &amp;lt;math&amp;gt;\mathcal{O}(n^3)&amp;lt;/math&amp;gt; (&amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; nodes and at most &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt; outgoing residual arcs per node).&lt;br /&gt;
&lt;br /&gt;
The argument in the [[Ahuja-Orlin#Complexity|complexity analysis]] of the [[Ahuja-Orlin]] algorithm to prove that the total number of ''saturating'' push operations is in &amp;lt;math&amp;gt;\mathcal{O}(nm)&amp;lt;/math&amp;gt;, applies here as well.&lt;br /&gt;
&lt;br /&gt;
Finally, we consider the ''non-saturating'' push operations. First note that &amp;lt;math&amp;gt;D\geq 0&amp;lt;/math&amp;gt; before and after each iteration. The value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; increases by less than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total over all relabel operations. On the other hand, a saturating push operation may increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by at most &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt; (namely, in the case that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; was not active immediately before the push). In summary, the total sum of all values by which &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased throughout the algorithm is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;. Due to the variant, the value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased by at least one in each non-saturating push operation. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Heuristic speedup techniques ==&lt;br /&gt;
&lt;br /&gt;
# After &amp;lt;math&amp;gt;\Omega(n)&amp;lt;/math&amp;gt; iterations of the main loop, the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-values are recomputed analogously to the induction basis: as the current distance of each node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.&lt;br /&gt;
# The main loop may be decomposed into two phases: First, as much flow as possible is sent into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;; second, all surplus flow that cannot reach &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is sent back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. The first phase may be finished once there is no more path in the residual network from any active node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. A sufficient and easy-to-check condition for that is &amp;lt;math&amp;gt;d(v)\geq n&amp;lt;/math&amp;gt; for all active nodes &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. All nodes from which &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2789</id>
		<title>Preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2789"/>
		<updated>2015-02-04T17:31:30Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Complexity */ Korrektur der Anzahl an Vorwärtsschritten der current arc&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Max-Flow Problems#Standard version|max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
loop.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A nonnegative integral value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node &amp;lt;math&amp;gt;v\in V\setminus\{t\}&amp;lt;/math&amp;gt; has a '''current arc''', which may be implemented as an iterator on the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The [[Basic flow definitions#Preflow|excess]] &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; of a node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; with respect to the current [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# A (dynamically changing) [[Sets and sequences|set]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of nodes.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; . If all upper bounds are integral, all &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral, too.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\} &amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;e_f(v)\geq 0&amp;lt;/math&amp;gt;. In other words, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# The node labels &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; form a [[Basic flow definitions#Valid distance labeling|valid distance labeling]], and it is &amp;lt;math&amp;gt;d(s)=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The currently [[Basic flow definitions#Preflow|active nodes]] are stored in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
In each iteration, one of the following three actions will take place:&lt;br /&gt;
# The label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of at least one node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; is increased.&lt;br /&gt;
# A saturating push is performed.&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;D:=\sum_{v\in V\setminus\{s,t\}\atop e_f(v)&amp;gt;0}d(v)&amp;lt;/math&amp;gt; decreases.&lt;br /&gt;
No label &amp;lt;math&amp;gt;d(\cdot)&amp;lt;/math&amp;gt; is ever decreased.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
&amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;f(a):=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;(s,v)\in A&amp;lt;/math&amp;gt;, overwrite this value by &amp;lt;math&amp;gt;f(a):=u(a)&amp;lt;/math&amp;gt; and put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Compute a [[Basic flow definitions#Valid distance labeling|valid distance labeling]] &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;, for example, the true distances from all nodes to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;d(s):=n&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the first arc in the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For the [[Basic graph definitions#Subgraphs|subgraph induced]] by &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt;, the arguments in the [[Ahuja-Orlin#Correctness|correctness proof]] for the [[Ahuja-Orlin]] algorithm prove that the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-labels form a valid distance labeling here as well. For &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, nothing is to show because all outgoing arcs are saturated.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Choose an [[Basic flow definitions#Preflow|active node]] &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and not [[Basic flow definitions#Valid distance labeling|admissible]] either, move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is ''not'' void now but an (admissible) outgoing arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;, say:&lt;br /&gt;
## If &amp;lt;math&amp;gt;w\neq s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_f(w)=0&amp;lt;/math&amp;gt;, insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase the flow over &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by the minimum of &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; and the residual capacity of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;e_f(w)&amp;lt;/math&amp;gt; by that value and decrease &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; by the same value.&lt;br /&gt;
## If &amp;lt;math&amp;gt;e_f(v)=0&amp;lt;/math&amp;gt; now, extract &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;d_\max&amp;lt;/math&amp;gt; denote the minimal label &amp;lt;math&amp;gt;d(w)&amp;lt;/math&amp;gt; of any arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the residual network.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;d(v):=d_\max+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the beginning of the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
The preflow-push algorithm is also known as the '''push-relabel''' algorithm. The ''push'' operation is step 3; the ''relabel'' operation is step 4.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Points 1, 2, and 4 of the invariant and &amp;lt;math&amp;gt;d(s)=n&amp;lt;/math&amp;gt; are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; ensures point 3 of the invariant.&lt;br /&gt;
&lt;br /&gt;
To prove the variant, consider a step in which neither any &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not saturated by that. Potentially, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; becomes active. However, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that &amp;lt;math&amp;gt;d(w)=d(v)-1&amp;lt;/math&amp;gt; for an admissible arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It remains to show termination; this is proved by the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show that the total number of relabel operations (step 4 of the main loop) is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with positive flow on all arcs. The [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is [[Basic flow definitions#Flow-augmenting paths and saturated arcs|augmenting]]. Due to the validity of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; (induction hypothesis), &amp;lt;math&amp;gt;d(v)-d(s)=d(v)-n&amp;lt;/math&amp;gt; cannot be larger than the number of arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, which is not larger than &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, no node label can be larger than &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;. Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.&lt;br /&gt;
&lt;br /&gt;
From this bound, we may immediately conclude that the current arc of a node is reset &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt; times, so the total number of forward steps of the current arcs of all nodes is in &amp;lt;math&amp;gt;\mathcal{O}(n^3)&amp;lt;/math&amp;gt; (&amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; nodes and at most &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt; outgoing residual arcs per node).&lt;br /&gt;
&lt;br /&gt;
The argument in the [[Ahuja-Orlin#Complexity|complexity analysis]] of the [[Ahuja-Orlin]] algorithm to prove that the total number of ''saturating'' push operations is in &amp;lt;math&amp;gt;\mathcal{O}(nm)&amp;lt;/math&amp;gt;, applies here as well.&lt;br /&gt;
&lt;br /&gt;
Finally, we consider the ''non-saturating'' push operations. First note that &amp;lt;math&amp;gt;D\geq 0&amp;lt;/math&amp;gt; before and after each iteration. The value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; increases by less than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total over all relabel operations. On the other hand, a saturating push operation may increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by at most &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt; (namely, in the case that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; was not active immediately before the push). In summary, the total sum of all values by which &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased throughout the algorithm is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;. Due to the variant, the value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased by at least one in each non-saturating push operation. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Heuristic speedup techniques ==&lt;br /&gt;
&lt;br /&gt;
# After &amp;lt;math&amp;gt;\Omega(n)&amp;lt;/math&amp;gt; iterations of the main loop, the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-values are recomputed analogously to the induction basis: as the current distance of each node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.&lt;br /&gt;
# The main loop may be decomposed into two phases: First, as much flow as possible is sent into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;; second, all surplus flow that cannot reach &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is sent back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. The first phase may be finished once there is no more path in the residual network from any active node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. A sufficient and easy-to-check condition for that is &amp;lt;math&amp;gt;d(v)\geq n&amp;lt;/math&amp;gt; for all active nodes &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. All nodes from which &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2788</id>
		<title>Preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2788"/>
		<updated>2015-02-03T19:32:11Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Max-Flow Problems#Standard version|max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
loop.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A nonnegative integral value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node &amp;lt;math&amp;gt;v\in V\setminus\{t\}&amp;lt;/math&amp;gt; has a '''current arc''', which may be implemented as an iterator on the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The [[Basic flow definitions#Preflow|excess]] &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; of a node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; with respect to the current [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# A (dynamically changing) [[Sets and sequences|set]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of nodes.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; . If all upper bounds are integral, all &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral, too.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\} &amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;e_f(v)\geq 0&amp;lt;/math&amp;gt;. In other words, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# The node labels &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; form a [[Basic flow definitions#Valid distance labeling|valid distance labeling]], and it is &amp;lt;math&amp;gt;d(s)=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The currently [[Basic flow definitions#Preflow|active nodes]] are stored in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
In each iteration, one of the following three actions will take place:&lt;br /&gt;
# The label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of at least one node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; is increased.&lt;br /&gt;
# A saturating push is performed.&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;D:=\sum_{v\in V\setminus\{s,t\}\atop e_f(v)&amp;gt;0}d(v)&amp;lt;/math&amp;gt; decreases.&lt;br /&gt;
No label &amp;lt;math&amp;gt;d(\cdot)&amp;lt;/math&amp;gt; is ever decreased.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
&amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;f(a):=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;(s,v)\in A&amp;lt;/math&amp;gt;, overwrite this value by &amp;lt;math&amp;gt;f(a):=u(a)&amp;lt;/math&amp;gt; and put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Compute a [[Basic flow definitions#Valid distance labeling|valid distance labeling]] &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;, for example, the true distances from all nodes to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;d(s):=n&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the first arc in the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For the [[Basic graph definitions#Subgraphs|subgraph induced]] by &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt;, the arguments in the [[Ahuja-Orlin#Correctness|correctness proof]] for the [[Ahuja-Orlin]] algorithm prove that the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-labels form a valid distance labeling here as well. For &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, nothing is to show because all outgoing arcs are saturated.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Choose an [[Basic flow definitions#Preflow|active node]] &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and not [[Basic flow definitions#Valid distance labeling|admissible]] either, move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is ''not'' void now but an (admissible) outgoing arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;, say:&lt;br /&gt;
## If &amp;lt;math&amp;gt;w\neq s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_f(w)=0&amp;lt;/math&amp;gt;, insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase the flow over &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by the minimum of &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; and the residual capacity of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;e_f(w)&amp;lt;/math&amp;gt; by that value and decrease &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; by the same value.&lt;br /&gt;
## If &amp;lt;math&amp;gt;e_f(v)=0&amp;lt;/math&amp;gt; now, extract &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;d_\max&amp;lt;/math&amp;gt; denote the minimal label &amp;lt;math&amp;gt;d(w)&amp;lt;/math&amp;gt; of any arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the residual network.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;d(v):=d_\max+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the beginning of the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
The preflow-push algorithm is also known as the '''push-relabel''' algorithm. The ''push'' operation is step 3; the ''relabel'' operation is step 4.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Points 1, 2, and 4 of the invariant and &amp;lt;math&amp;gt;d(s)=n&amp;lt;/math&amp;gt; are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; ensures point 3 of the invariant.&lt;br /&gt;
&lt;br /&gt;
To prove the variant, consider a step in which neither any &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not saturated by that. Potentially, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; becomes active. However, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that &amp;lt;math&amp;gt;d(w)=d(v)-1&amp;lt;/math&amp;gt; for an admissible arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It remains to show termination; this is proved by the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show that the total number of relabel operations (step 4 of the main loop) is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with positive flow on all arcs. The [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is [[Basic flow definitions#Flow-augmenting paths and saturated arcs|augmenting]]. Due to the validity of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; (induction hypothesis), &amp;lt;math&amp;gt;d(v)-d(s)=d(v)-n&amp;lt;/math&amp;gt; cannot be larger than the number of arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, which is not larger than &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, no node label can be larger than &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;. Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.&lt;br /&gt;
&lt;br /&gt;
From this bound, we may immediately conclude that the current arc of a node is reset &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt; times, so the total number of forward steps of the current arcs of all nodes is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The argument in the [[Ahuja-Orlin#Complexity|complexity analysis]] of the [[Ahuja-Orlin]] algorithm to prove that the total number of ''saturating'' push operations is in &amp;lt;math&amp;gt;\mathcal{O}(nm)&amp;lt;/math&amp;gt;, applies here as well.&lt;br /&gt;
&lt;br /&gt;
Finally, we consider the ''non-saturating'' push operations. First note that &amp;lt;math&amp;gt;D\geq 0&amp;lt;/math&amp;gt; before and after each iteration. The value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; increases by less than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total over all relabel operations. On the other hand, a saturating push operation may increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by at most &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt; (namely, in the case that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; was not active immediately before the push). In summary, the total sum of all values by which &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased throughout the algorithm is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;. Due to the variant, the value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased by at least one in each non-saturating push operation. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Heuristic speedup techniques ==&lt;br /&gt;
&lt;br /&gt;
# After &amp;lt;math&amp;gt;\Omega(n)&amp;lt;/math&amp;gt; iterations of the main loop, the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-values are recomputed analogously to the induction basis: as the current distance of each node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.&lt;br /&gt;
# The main loop may be decomposed into two phases: First, as much flow as possible is sent into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;; second, all surplus flow that cannot reach &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is sent back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. The first phase may be finished once there is no more path in the residual network from any active node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. A sufficient and easy-to-check condition for that is &amp;lt;math&amp;gt;d(v)\geq n&amp;lt;/math&amp;gt; for all active nodes &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. All nodes from which &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dinic&amp;diff=2727</id>
		<title>Dinic</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dinic&amp;diff=2727"/>
		<updated>2015-01-08T10:43:29Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction step */ auch V wird i.A. reduziert&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Max-Flow Problems#Standard version|Max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm :''' loop.&lt;br /&gt;
&lt;br /&gt;
== Abstract View ==&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
After &amp;lt;math&amp;gt;i \ge 0&amp;lt;/math&amp;gt; iterations:&lt;br /&gt;
#The flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is feasible.&lt;br /&gt;
# If all upper bounds are integral, the &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral as well.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
The smallest number of arcs on a flow-augmenting &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path strictly increases.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:''' There is no flow-augmenting &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path anymore.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
Initialize &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; as an arbitrary feasible flow, for example, the zero flow.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Nothing to show.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Construct the [[Basic graph definitions#Cycles|acyclic]]  [[Basic graph definitions#Subgraphs|subgraph]] &amp;lt;math&amp;gt;G'=(V',A')&amp;lt;/math&amp;gt; of the residual network that contains an arc if, and only if, the arc is on at least one &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path with smallest number of arcs (and contains all nodes incident to these arcs).&lt;br /&gt;
# Use one of the algorithms for the [[Blocking flow|blocking flow]] problem to construct a blocking flow &amp;lt;math&amp;gt;f'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; with respect to the residual capacities for &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Add &amp;lt;math&amp;gt;f'&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Obvious.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Feasibility of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; follows immediately from the invariant. If the algorithm terminates, the break condition immediately proves maximality along with the [[Max-flow min-cut|max-flow min-cut theorem]]. Termination follows immediately from the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n\cdot T(n,m))&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;T(n,m)&amp;lt;/math&amp;gt; is the asymptotic complexity of the blocking-flow algorithm.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Evidenty, the smallest number of arcs on a flow-augmenting &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path cannot exceed &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, the variant implies that the algorithm terminates after &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt; iterations. The complexity of a single iteration is dominated by the computation of a blocking flow.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-flow_min-cut&amp;diff=2726</id>
		<title>Max-flow min-cut</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-flow_min-cut&amp;diff=2726"/>
		<updated>2015-01-03T09:29:23Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Proof */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Max-flow min-cut theorem ==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s,t\in V&amp;lt;/math&amp;gt;, and for &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; be real values such that &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow]]. Then the following three statements are equivalent:&lt;br /&gt;
# The [[Basic flow definitions#Flow value|flow value]] of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum among all [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flows]].&lt;br /&gt;
# There is a [[Basic flow definitions#Cuts and saturated cuts|saturated cut]].&lt;br /&gt;
# There is no [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting path]] from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Proof ==&lt;br /&gt;
&lt;br /&gt;
First suppose there is no [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting path]] from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; denote the set of all nodes reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; via flow-augmenting paths, and let &amp;lt;math&amp;gt;T:=V\setminus S&amp;lt;/math&amp;gt;. Then we have &amp;lt;math&amp;gt;s\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t\in T&amp;lt;/math&amp;gt;. Obviously, &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; is [[Basic flow definitions#Cuts and saturated cuts|saturated]].&lt;br /&gt;
&lt;br /&gt;
Next suppose there is a [[Basic flow definitions#Cuts and saturated cuts|saturated]] cut. No flow &amp;lt;math&amp;gt;f'&amp;lt;/math&amp;gt; can carry more units of flow value from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; than the capacity of any [[Basic flow definitions#Cuts and saturated cuts|&amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-cut]] allows. Consequently, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum.&lt;br /&gt;
&lt;br /&gt;
Finally suppose &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum. Clearly, then a [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting path]] from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; cannot exist.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-flow_min-cut&amp;diff=2725</id>
		<title>Max-flow min-cut</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-flow_min-cut&amp;diff=2725"/>
		<updated>2015-01-03T09:27:12Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Proof */ Konkretisierung der Formulierung + Links eingefügt&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Max-flow min-cut theorem ==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s,t\in V&amp;lt;/math&amp;gt;, and for &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; be real values such that &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow]]. Then the following three statements are equivalent:&lt;br /&gt;
# The [[Basic flow definitions#Flow value|flow value]] of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum among all [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flows]].&lt;br /&gt;
# There is a [[Basic flow definitions#Cuts and saturated cuts|saturated cut]].&lt;br /&gt;
# There is no [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting path]] from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Proof ==&lt;br /&gt;
&lt;br /&gt;
First suppose there is no [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting path]] from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; denote the set of all nodes reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; via flow-augmenting paths, and let &amp;lt;math&amp;gt;T:=V\setminus S&amp;lt;/math&amp;gt;. Then we have &amp;lt;math&amp;gt;s\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t\in T&amp;lt;/math&amp;gt;. Obviously, &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; is [[Basic flow definitions#Cuts and saturated cuts|saturated]].&lt;br /&gt;
&lt;br /&gt;
Next suppose there is a [[Basic flow definitions#Cuts and saturated cuts|saturated]] cut. No flow &amp;lt;math&amp;gt;f'&amp;lt;/math&amp;gt; can carry more units of flow value from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; than the capacity of any [[Basic flow definitions#Cuts and saturated cuts|&amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-cut]] allows. Consequently, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum.&lt;br /&gt;
&lt;br /&gt;
Finally suppose &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum. Clearly, then a [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting path]] cannot exist.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-flow_min-cut&amp;diff=2724</id>
		<title>Max-flow min-cut</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-flow_min-cut&amp;diff=2724"/>
		<updated>2015-01-03T09:19:21Z</updated>

		<summary type="html">&lt;p&gt;BB91: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Max-flow min-cut theorem ==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s,t\in V&amp;lt;/math&amp;gt;, and for &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; be real values such that &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow]]. Then the following three statements are equivalent:&lt;br /&gt;
# The [[Basic flow definitions#Flow value|flow value]] of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum among all [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flows]].&lt;br /&gt;
# There is a [[Basic flow definitions#Cuts and saturated cuts|saturated cut]].&lt;br /&gt;
# There is no [[Basic flow definitions#Flow-augmenting paths and saturated arcs|flow-augmenting path]] from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Proof ==&lt;br /&gt;
&lt;br /&gt;
First suppose there is no flow-augmenting path from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; denote the set of all nodes reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; via flow-augmenting paths, and let &amp;lt;math&amp;gt;T:=V\setminus S&amp;lt;/math&amp;gt;. Then we have &amp;lt;math&amp;gt;s\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t\in T&amp;lt;/math&amp;gt;. Obviously, &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; is saturated.&lt;br /&gt;
&lt;br /&gt;
Next suppose there is a saturated cut. No flow &amp;lt;math&amp;gt;f'&amp;lt;/math&amp;gt; can carry more units of flow value from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; than the capacity of any cut allows. Consequently, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum.&lt;br /&gt;
&lt;br /&gt;
Finally suppose &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is maximum. Clearly, then a flow-augmenting path cannot exist.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-Flow_Problems&amp;diff=2723</id>
		<title>Max-Flow Problems</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-Flow_Problems&amp;diff=2723"/>
		<updated>2015-01-02T16:18:18Z</updated>

		<summary type="html">&lt;p&gt;BB91: Undo revision 2722 by BB91 (talk) Irrtum&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic definitions ==&lt;br /&gt;
&lt;br /&gt;
# [[Basic graph definitions]]&lt;br /&gt;
# [[Basic flow definitions]]&lt;br /&gt;
&lt;br /&gt;
== Standard version ==&lt;br /&gt;
&lt;br /&gt;
'''Input:'''&lt;br /&gt;
# A directed graph &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''source node''' &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt; and a '''target (a.k.a. sink) node''' &amp;lt;math&amp;gt;t\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A nonnegative '''upper bound (a.k.a. capacity)''' &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; for each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
A [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow]] that has maximum [[Basic flow definitions#Flow value|flow value]] among all feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flows.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
# [[Ford-Fulkerson]]&lt;br /&gt;
# [[Edmonds-Karp]]&lt;br /&gt;
# [[Ahuja-Orlin]]&lt;br /&gt;
# [[Dinic]]&lt;br /&gt;
# [[Preflow-push]]&lt;br /&gt;
# [[FIFO preflow-push]]&lt;br /&gt;
# [[Preflow-push with excess scaling]]&lt;br /&gt;
&lt;br /&gt;
== Generalizations ==&lt;br /&gt;
&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, there is a '''lower bound''' &amp;lt;math&amp;gt;\ell(a)&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;f(a)\geq\ell(a)&amp;lt;/math&amp;gt; is additionally required. The lower bounds need not be nonnegative, so the flow values need not be nonnegative, either. This version is often called '''maximum flow with edge demands'''. It may be reduced to solving two instances of the standard version as follows:&lt;br /&gt;
## First, we construct a new graph &amp;lt;math&amp;gt;G'=(V',A')&amp;lt;/math&amp;gt; as follows: We add a super-source &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; and a super-target &amp;lt;math&amp;gt;t'&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;. Next,  for every node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, we add an arc &amp;lt;math&amp;gt;(s',v)&amp;lt;/math&amp;gt; and an arc &amp;lt;math&amp;gt;(v,t')&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;. Finally we add an arc &amp;lt;math&amp;gt;(t,s)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;, if not in &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; yet.&lt;br /&gt;
## For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, we set &amp;lt;math&amp;gt;\ell'(a):=0&amp;lt;/math&amp;gt;. For each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, we set &lt;br /&gt;
##:&amp;lt;math&amp;gt;u'(s',v):=\sum_{(w,v)\in A}\ell(w,v)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u'(v,t'):=\sum_{(v,w)\in A} \ell(v,w)&amp;lt;/math&amp;gt;. &lt;br /&gt;
##:For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, we set &amp;lt;math&amp;gt;u'(a):=u(a)-\ell(a)&amp;lt;/math&amp;gt;. Finally, we set &amp;lt;math&amp;gt;u'(t,s):=+\infty&amp;lt;/math&amp;gt;.&lt;br /&gt;
## It is easy to see that there is a feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;\ell&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; if, and only if, all arcs &amp;lt;math&amp;gt;(s',\cdot)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(\cdot,t')&amp;lt;/math&amp;gt; are saturated. This the case if, and only if, the maximum flow &amp;lt;math&amp;gt;f'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t'&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;\ell'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u'&amp;lt;/math&amp;gt; yields a flow of value &amp;lt;math&amp;gt;\sum_{a\in A}\ell(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## More specifically, for &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt;, we set &amp;lt;math&amp;gt;f(v,w):=f'(v,w)+\ell(v,w)&amp;lt;/math&amp;gt;.[[File:Maxflowmultiplesource.png|350px|thumb|right|Max-Flow Problem with several sources and targets]]&lt;br /&gt;
# More than one source and more than one target can be reduced to the standard version by adding a super-source node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, a super-target node &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;, an arc &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt; with &amp;quot;infinite&amp;quot; capacity for each source &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, and an arc &amp;lt;math&amp;gt;(v,t)&amp;lt;/math&amp;gt; with &amp;quot;infinite&amp;quot; capacity for each target &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; (for example, the sum of the upper bounds of all arcs is sufficiently large to serve as &amp;quot;infinity&amp;quot;).&lt;br /&gt;
# Usually, the term '''generalized flow''' is reserved for the specific generalization in which for each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, the ratio of the total sum of all incoming flow an the total sum of all outgoing flow is given (in the standard version, this ratio is 1 due to the flow conservation condition).&lt;br /&gt;
# The max-flow problem asks for an optimal steady-state flow. However, in many applications, a certain amount of flow is to be sent as soon as possible from the source to the target. It is easy to see that, if the amount of flow is sufficiently large, then an optimal solution is constant most of the time, and the maximum steady-state flow is this constant flow.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-Flow_Problems&amp;diff=2722</id>
		<title>Max-Flow Problems</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-Flow_Problems&amp;diff=2722"/>
		<updated>2015-01-02T16:05:28Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Generalizations */ Hilfskapazitäten&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic definitions ==&lt;br /&gt;
&lt;br /&gt;
# [[Basic graph definitions]]&lt;br /&gt;
# [[Basic flow definitions]]&lt;br /&gt;
&lt;br /&gt;
== Standard version ==&lt;br /&gt;
&lt;br /&gt;
'''Input:'''&lt;br /&gt;
# A directed graph &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''source node''' &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt; and a '''target (a.k.a. sink) node''' &amp;lt;math&amp;gt;t\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A nonnegative '''upper bound (a.k.a. capacity)''' &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; for each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
A [[Basic flow definitions#Feasible flow|feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow]] that has maximum [[Basic flow definitions#Flow value|flow value]] among all feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flows.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
# [[Ford-Fulkerson]]&lt;br /&gt;
# [[Edmonds-Karp]]&lt;br /&gt;
# [[Ahuja-Orlin]]&lt;br /&gt;
# [[Dinic]]&lt;br /&gt;
# [[Preflow-push]]&lt;br /&gt;
# [[FIFO preflow-push]]&lt;br /&gt;
# [[Preflow-push with excess scaling]]&lt;br /&gt;
&lt;br /&gt;
== Generalizations ==&lt;br /&gt;
&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, there is a '''lower bound''' &amp;lt;math&amp;gt;\ell(a)&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;f(a)\geq\ell(a)&amp;lt;/math&amp;gt; is additionally required. The lower bounds need not be nonnegative, so the flow values need not be nonnegative, either. This version is often called '''maximum flow with edge demands'''. It may be reduced to solving two instances of the standard version as follows:&lt;br /&gt;
## First, we construct a new graph &amp;lt;math&amp;gt;G'=(V',A')&amp;lt;/math&amp;gt; as follows: We add a super-source &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; and a super-target &amp;lt;math&amp;gt;t'&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;. Next,  for every node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, we add an arc &amp;lt;math&amp;gt;(s',v)&amp;lt;/math&amp;gt; and an arc &amp;lt;math&amp;gt;(v,t')&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;. Finally we add an arc &amp;lt;math&amp;gt;(t,s)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;, if not in &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; yet.&lt;br /&gt;
## For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, we set &amp;lt;math&amp;gt;\ell'(a):=0&amp;lt;/math&amp;gt;. For each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, we set &lt;br /&gt;
##:&amp;lt;math&amp;gt;u'(s',v):=\sum_{(v,w)\in A} \ell(v,w)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u'(v,t'):=\sum_{(w,v)\in A}\ell(w,v)&amp;lt;/math&amp;gt;. &lt;br /&gt;
##:For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, we set &amp;lt;math&amp;gt;u'(a):=u(a)-\ell(a)&amp;lt;/math&amp;gt;. Finally, we set &amp;lt;math&amp;gt;u'(t,s):=+\infty&amp;lt;/math&amp;gt;.&lt;br /&gt;
## It is easy to see that there is a feasible &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;\ell&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; if, and only if, all arcs &amp;lt;math&amp;gt;(s',\cdot)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(\cdot,t')&amp;lt;/math&amp;gt; are saturated. This the case if, and only if, the maximum flow &amp;lt;math&amp;gt;f'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;t'&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;\ell'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u'&amp;lt;/math&amp;gt; yields a flow of value &amp;lt;math&amp;gt;\sum_{a\in A}\ell(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## More specifically, for &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt;, we set &amp;lt;math&amp;gt;f(v,w):=f'(v,w)+\ell(v,w)&amp;lt;/math&amp;gt;.[[File:Maxflowmultiplesource.png|350px|thumb|right|Max-Flow Problem with several sources and targets]]&lt;br /&gt;
# More than one source and more than one target can be reduced to the standard version by adding a super-source node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, a super-target node &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;, an arc &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt; with &amp;quot;infinite&amp;quot; capacity for each source &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, and an arc &amp;lt;math&amp;gt;(v,t)&amp;lt;/math&amp;gt; with &amp;quot;infinite&amp;quot; capacity for each target &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; (for example, the sum of the upper bounds of all arcs is sufficiently large to serve as &amp;quot;infinity&amp;quot;).&lt;br /&gt;
# Usually, the term '''generalized flow''' is reserved for the specific generalization in which for each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, the ratio of the total sum of all incoming flow an the total sum of all outgoing flow is given (in the standard version, this ratio is 1 due to the flow conservation condition).&lt;br /&gt;
# The max-flow problem asks for an optimal steady-state flow. However, in many applications, a certain amount of flow is to be sent as soon as possible from the source to the target. It is easy to see that, if the amount of flow is sufficiently large, then an optimal solution is constant most of the time, and the maximum steady-state flow is this constant flow.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2721</id>
		<title>Branching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2721"/>
		<updated>2015-01-02T11:19:38Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Maximum branching]]&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# An arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; is '''critical''' for &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if its weight is not smaller than the weight of any other incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''critical subgraph''' &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains exactly one incoming arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; of positive indegree, where &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is critical.&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' The output of a recursive call is a maximum branching of the weighted graph that was the input for this recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Terminate if &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free, it is a branching. Consider some other branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; does not have more total weight than &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By definition, a critical graph contains one incoming arc for each node that does have incoming arcs. Therefore, for each arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, there is an arc &amp;lt;math&amp;gt;a'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; pointing to the same node. Due to the choice of arcs for &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;w(a)\leq w(a')&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
[[File:Edmonds max branching ani 10000.gif|thumb|350px|''animated gif:'' Branching by Edmonds]]&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Compute a critical subgraph &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; for the input graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Identify some cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; denote the minimum weight of all arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; pointing from some node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;:&lt;br /&gt;
##Decrease the weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;w(v',w)-W\geq 0&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;(v',w)&amp;lt;/math&amp;gt; is the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If the new weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not positive, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Shrink &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; into one new super-node, where every arc pointing to (resp., from)  some node on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; now points to (from) that super-node.&lt;br /&gt;
# Call the algorithm recursively for the modified weighted graph after shrinking, giving branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Unshrink the graph.&lt;br /&gt;
# Add all arcs of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; contains an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;: remove the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;; otherwise, remove one arc with weight &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; be the result in both cases.&lt;br /&gt;
# Return &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; is a branching, so we have to prove that it has maximum weight among all branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; be a maximum branching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that, among all maximum branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; shares as many arcs as possible with &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be a cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; (the case &amp;lt;math&amp;gt;C'=C&amp;lt;/math&amp;gt; not excluded). First we show that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; except one. So, suppose for a contradiction that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; does not contain some of the arcs  of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;, say, &amp;lt;math&amp;gt;(v_1,w_1),\ldots,(v_k,w_k)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;k&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Replacing the incoming arc of any &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and doing nothing else, would not decrease the total weight. Since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;, such a replacement cannot result in a branching anymore. Since the indegrees do not change by that replacement, this means that adding &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; would close a cycle. In other words, there is a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt;. Each path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; must enter &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; at one of the nodes &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; (actually at the nearest &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; looking backwards from &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;) because, otherwise, the node where &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; had two incoming arcs in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;: the incoming arc on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; and the arc over which &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. However, this would imply that there is a cycle in the union of all paths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;. This union is a subset of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;, which yields the desired contradiction.&lt;br /&gt;
&lt;br /&gt;
Now we know that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs except one on all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. Note that, for any node not on a cycle, the incoming branching arc may be freely chosen (except for arcs which would close a cycle) without any effect on the rest. So, since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; agree on all of these choices. Further note that all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; are node-disjoint. In summary, we may compare &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; on each cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; separately.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;, complete agreement between &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; follows from the observation that the choice of incoming arcs for all nodes on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is optimal in &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; due to the specific modification of the arc weights. And for all other cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, complete agreement follows from the induction hypothesis. In both cases, we again used the specific choice of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; to be as close to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; as possible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}((n+m)\cdot n)&amp;lt;/math&amp;gt; in the worst case, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Using [[Depth-first search|DFS]] for cycle detection, each recursive step requires &amp;lt;math&amp;gt;\mathcal{O}(n+m)&amp;lt;/math&amp;gt;. In each shrink operation, the number of nodes decreases, so the recursion depth is &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
More sophisticated implementations of this algorithm yield better asymptotic complexities.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The unshrink operation requires that the shrink operation performs some bookkeeping: For the super-node, a cyclically ordered sequence of all nodes and arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; (or an equivalent bulk of information) must be attached to a super-node.&lt;br /&gt;
# Several cycles may be discovered simultaneously by one run of [[Depth-first search|DFS]]. Note that all cycles in a critical graph are node-disjoint, because no node has more than one incoming arc. Therefore, several cycles may be handled in the same recursive call, without any interference.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2720</id>
		<title>Branching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2720"/>
		<updated>2015-01-02T11:09:30Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */ Tipp zur Veranschaulichung&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Maximum branching]]&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# An arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; is '''critical''' for &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if its weight is not smaller than the weight of any other incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''critical subgraph''' &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains exactly one incoming arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; of positive indegree, where &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is critical.&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' The output of a recursive call is a maximum branching of the weighted graph that was the input for this recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Terminate if &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free, it is a branching. Consider some other branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; does not have more total weight than &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By definition, a critical graph contains one incoming arc for each node that does have incoming arcs. Therefore, for each arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, there is an arc &amp;lt;math&amp;gt;a'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; pointing to the same node. Due to the choice of arcs for &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;w(a)\leq w(a')&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
[[File:Edmonds max branching ani 10000.gif|thumb|350px|''animated gif:'' Branching by Edmonds]]&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Compute a critical subgraph &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; for the input graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Identify some cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; denote the minimum weight of all arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; pointing from some node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;:&lt;br /&gt;
##Decrease the weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;w(v',w)-W\geq 0&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;(v',w)&amp;lt;/math&amp;gt; is the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If the new weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not positive, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Shrink &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; into one new super-node, where every arc pointing to (resp., from)  some node on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; now points to (from) that super-node.&lt;br /&gt;
# Call the algorithm recursively for the modified weighted graph after shrinking, giving branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Unshrink the graph.&lt;br /&gt;
# Add all arcs of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; contains an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;: remove the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;; otherwise, remove one arc with weight &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; be the result in both cases.&lt;br /&gt;
# Return &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; is a branching, so we have to prove that it has maximum weight among all branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; be a maximum branching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that, among all maximum branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; shares as many arcs as possible with &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be a cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; (the case &amp;lt;math&amp;gt;C'=C&amp;lt;/math&amp;gt; not excluded). First we show that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; except one. So, suppose for a contradiction that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; does not contain some of the arcs  of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;, say, &amp;lt;math&amp;gt;(v_1,w_1),\ldots,(v_k,w_k)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;k&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Replacing the incoming arc of any &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and doing nothing else, would not decrease the total weight. Since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;, such a replacement cannot result in a branching anymore. Since the indegrees do not change by that replacement, this means that adding &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; would close a cycle. In other words, there is a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt;. Each path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; must enter &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; at one of the nodes &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; (actually at the nearest &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; looking backwards from &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;) because, otherwise, the node where &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; had two incoming arcs in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;: the incoming arc on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; and the arc over which &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. However, this would imply that there is a cycle in the union of all paths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;. This union is a subset of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;, which yields the desired contradiction.&lt;br /&gt;
&lt;br /&gt;
Now we know that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs except one on all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. Note that, for any node not on a cycle, the incoming branching arc may be freely chosen without any effect on the rest. So, since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; agree on all of these choices. Further note that all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; are node-disjoint. In summary, we may compare &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; on each cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; separately.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;, complete agreement between &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; follows from the observation that the choice of incoming arcs for all nodes on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is optimal in &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; due to the specific modification of the arc weights. And for all other cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, complete agreement follows from the induction hypothesis. In both cases, we again used the specific choice of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; to be as close to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; as possible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}((n+m)\cdot n)&amp;lt;/math&amp;gt; in the worst case, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Using [[Depth-first search|DFS]] for cycle detection, each recursive step requires &amp;lt;math&amp;gt;\mathcal{O}(n+m)&amp;lt;/math&amp;gt;. In each shrink operation, the number of nodes decreases, so the recursion depth is &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
More sophisticated implementations of this algorithm yield better asymptotic complexities.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The unshrink operation requires that the shrink operation performs some bookkeeping: For the super-node, a cyclically ordered sequence of all nodes and arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; (or an equivalent bulk of information) must be attached to a super-node.&lt;br /&gt;
# Several cycles may be discovered simultaneously by one run of [[Depth-first search|DFS]]. Note that all cycles in a critical graph are node-disjoint, because no node has more than one incoming arc. Therefore, several cycles may be handled in the same recursive call, without any interference.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2719</id>
		<title>Branching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2719"/>
		<updated>2015-01-02T11:01:57Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */ bereits in Vereinigung der p_i liegt der Zykel&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Maximum branching]]&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# An arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; is '''critical''' for &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if its weight is not smaller than the weight of any other incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''critical subgraph''' &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains exactly one incoming arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; of positive indegree, where &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is critical.&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' The output of a recursive call is a maximum branching of the weighted graph that was the input for this recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Terminate if &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free, it is a branching. Consider some other branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; does not have more total weight than &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By definition, a critical graph contains one incoming arc for each node that does have incoming arcs. Therefore, for each arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, there is an arc &amp;lt;math&amp;gt;a'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; pointing to the same node. Due to the choice of arcs for &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;w(a)\leq w(a')&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
[[File:Edmonds max branching ani 10000.gif|thumb|350px|''animated gif:'' Branching by Edmonds]]&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Compute a critical subgraph &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; for the input graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Identify some cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; denote the minimum weight of all arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; pointing from some node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;:&lt;br /&gt;
##Decrease the weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;w(v',w)-W\geq 0&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;(v',w)&amp;lt;/math&amp;gt; is the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If the new weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not positive, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Shrink &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; into one new super-node, where every arc pointing to (resp., from)  some node on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; now points to (from) that super-node.&lt;br /&gt;
# Call the algorithm recursively for the modified weighted graph after shrinking, giving branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Unshrink the graph.&lt;br /&gt;
# Add all arcs of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; contains an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;: remove the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;; otherwise, remove one arc with weight &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; be the result in both cases.&lt;br /&gt;
# Return &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; is a branching, so we have to prove that it has maximum weight among all branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; be a maximum branching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that, among all maximum branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; shares as many arcs as possible with &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be a cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; (the case &amp;lt;math&amp;gt;C'=C&amp;lt;/math&amp;gt; not excluded). First we show that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; except one. So, suppose for a contradiction that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; does not contain some of the arcs  of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;, say, &amp;lt;math&amp;gt;(v_1,w_1),\ldots,(v_k,w_k)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;k&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Replacing the incoming arc of any &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and doing nothing else, would not decrease the total weight. Since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;, such a replacement cannot result in a branching anymore. Since the indegrees do not change by that replacement, this means that adding &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; would close a cycle. In other words, there is a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt;. Each path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; must enter &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; at one of the nodes &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; because, otherwise, the node where &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; had two incoming arcs in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;: the incoming arc on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; and the arc over which &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. However, this would imply that there is a cycle in the union of all paths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt;. This union is a subset of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;, which yields the desired contradiction.&lt;br /&gt;
&lt;br /&gt;
Now we know that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs except one on all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. Note that, for any node not on a cycle, the incoming branching arc may be freely chosen without any effect on the rest. So, since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; agree on all of these choices. Further note that all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; are node-disjoint. In summary, we may compare &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; on each cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; separately.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;, complete agreement between &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; follows from the observation that the choice of incoming arcs for all nodes on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is optimal in &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; due to the specific modification of the arc weights. And for all other cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, complete agreement follows from the induction hypothesis. In both cases, we again used the specific choice of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; to be as close to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; as possible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}((n+m)\cdot n)&amp;lt;/math&amp;gt; in the worst case, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Using [[Depth-first search|DFS]] for cycle detection, each recursive step requires &amp;lt;math&amp;gt;\mathcal{O}(n+m)&amp;lt;/math&amp;gt;. In each shrink operation, the number of nodes decreases, so the recursion depth is &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
More sophisticated implementations of this algorithm yield better asymptotic complexities.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The unshrink operation requires that the shrink operation performs some bookkeeping: For the super-node, a cyclically ordered sequence of all nodes and arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; (or an equivalent bulk of information) must be attached to a super-node.&lt;br /&gt;
# Several cycles may be discovered simultaneously by one run of [[Depth-first search|DFS]]. Note that all cycles in a critical graph are node-disjoint, because no node has more than one incoming arc. Therefore, several cycles may be handled in the same recursive call, without any interference.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2718</id>
		<title>Branching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2718"/>
		<updated>2015-01-02T10:44:28Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Maximum branching]]&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# An arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; is '''critical''' for &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if its weight is not smaller than the weight of any other incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''critical subgraph''' &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains exactly one incoming arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; of positive indegree, where &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is critical.&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' The output of a recursive call is a maximum branching of the weighted graph that was the input for this recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Terminate if &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free, it is a branching. Consider some other branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; does not have more total weight than &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By definition, a critical graph contains one incoming arc for each node that does have incoming arcs. Therefore, for each arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, there is an arc &amp;lt;math&amp;gt;a'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; pointing to the same node. Due to the choice of arcs for &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;w(a)\leq w(a')&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
[[File:Edmonds max branching ani 10000.gif|thumb|350px|''animated gif:'' Branching by Edmonds]]&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Compute a critical subgraph &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; for the input graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Identify some cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; denote the minimum weight of all arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; pointing from some node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;:&lt;br /&gt;
##Decrease the weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;w(v',w)-W\geq 0&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;(v',w)&amp;lt;/math&amp;gt; is the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If the new weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not positive, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Shrink &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; into one new super-node, where every arc pointing to (resp., from)  some node on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; now points to (from) that super-node.&lt;br /&gt;
# Call the algorithm recursively for the modified weighted graph after shrinking, giving branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Unshrink the graph.&lt;br /&gt;
# Add all arcs of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; contains an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;: remove the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;; otherwise, remove one arc with weight &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; be the result in both cases.&lt;br /&gt;
# Return &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; is a branching, so we have to prove that it has maximum weight among all branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; be a maximum branching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that, among all maximum branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; shares as many arcs as possible with &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be a cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; (the case &amp;lt;math&amp;gt;C'=C&amp;lt;/math&amp;gt; not excluded). First we show that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; except one. So, suppose for a contradiction that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; does not contain some of the arcs  of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;, say, &amp;lt;math&amp;gt;(v_1,w_1),\ldots,(v_k,w_k)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;k&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Replacing the incoming arc of any &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and doing nothing else, would not decrease the total weight. Since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;, such a replacement cannot result in a branching anymore. Since the indegrees do not change by that replacement, this means that adding &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; would close a cycle. In other words, there is a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt;. Each path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; must enter &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; at one of the nodes &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; because, otherwise, the node where &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; had two incoming arcs in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;: the incoming arc on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; and the arc over which &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. However, this would imply that there is a cycle in the union of all paths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; plus all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; '''not''' in &amp;lt;math&amp;gt;\{(v_1,w_1),\ldots,(v_k,w_k)\}&amp;lt;/math&amp;gt;. This union is a subset of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;, which yields the desired contradiction.&lt;br /&gt;
&lt;br /&gt;
Now we know that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs except one on all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. Note that, for any node not on a cycle, the incoming branching arc may be freely chosen without any effect on the rest. So, since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; agree on all of these choices. Further note that all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; are node-disjoint. In summary, we may compare &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; on each cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; separately.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;, complete agreement between &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; follows from the observation that the choice of incoming arcs for all nodes on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is optimal in &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; due to the specific modification of the arc weights. And for all other cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, complete agreement follows from the induction hypothesis. In both cases, we again used the specific choice of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; to be as close to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; as possible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}((n+m)\cdot n)&amp;lt;/math&amp;gt; in the worst case, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Using [[Depth-first search|DFS]] for cycle detection, each recursive step requires &amp;lt;math&amp;gt;\mathcal{O}(n+m)&amp;lt;/math&amp;gt;. In each shrink operation, the number of nodes decreases, so the recursion depth is &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
More sophisticated implementations of this algorithm yield better asymptotic complexities.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The unshrink operation requires that the shrink operation performs some bookkeeping: For the super-node, a cyclically ordered sequence of all nodes and arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; (or an equivalent bulk of information) must be attached to a super-node.&lt;br /&gt;
# Several cycles may be discovered simultaneously by one run of [[Depth-first search|DFS]]. Note that all cycles in a critical graph are node-disjoint, because no node has more than one incoming arc. Therefore, several cycles may be handled in the same recursive call, without any interference.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2717</id>
		<title>Branching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2717"/>
		<updated>2015-01-02T10:41:49Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Maximum branching]]&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# An arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; is '''critical''' for &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if its weight is not smaller than the weight of any other incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''critical subgraph''' &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains exactly one incoming arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; of positive indegree, where &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is critical.&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' The output of a recursive call is a maximum branching of the weighted graph that was the input for this recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Terminate if &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free, it is a branching. Consider some other branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; does not have more total weight than &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By definition, a critical graph contains one incoming arc for each node that does have incoming arcs. Therefore, for each arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, there is an arc &amp;lt;math&amp;gt;a'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; pointing to the same node. Due to the choice of arcs for &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;w(a)\leq w(a')&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
[[File:Edmonds max branching ani 10000.gif|thumb|350px|''animated gif:'' Branching by Edmonds]]&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Compute a critical subgraph &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; for the input graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Identify some cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; denote the minimum weight of all arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; pointing from some node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;:&lt;br /&gt;
##Decrease the weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;w(v',w)-W\geq 0&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;(v',w)&amp;lt;/math&amp;gt; is the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If the new weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not positive, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Shrink &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; into one new super-node, where every arc pointing to (resp., from)  some node on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; now points to (from) that super-node.&lt;br /&gt;
# Call the algorithm recursively for the modified weighted graph after shrinking, giving branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Unshrink the graph.&lt;br /&gt;
# Add all arcs of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; contains an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;: remove the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;; otherwise, remove one arc with weight &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; be the result in both cases.&lt;br /&gt;
# Return &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; is a branching, so we have to prove that it has maximum weight among all branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; be a maximum branching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that, among all maximum branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; shares as many arcs as possible with &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be a cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; (the case &amp;lt;math&amp;gt;C'=C&amp;lt;/math&amp;gt; not excluded). First we show that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; except one. So, suppose for a contradiction that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; does not contain some of the arcs  of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;, say, &amp;lt;math&amp;gt;(v_1,w_1),\ldots,(v_k,w_k)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;k&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Replacing the incoming arc of any &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and doing nothing else, would not decrease the total weight. Since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;, such a replacement cannot result in a branching anymore. Since the indegrees do not change by that replacement, this means that adding &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; would close a cycle. In other words, there is a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt;. Each path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; must enter &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; at one of the nodes &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; because, otherwise, the node where &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; had two incoming arcs in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;: the incoming arc on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; and the arc over which &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. However, this would imply that there is a cycle in the union of all paths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; plus all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; '''not''' in &amp;lt;math&amp;gt;\{(v_1,w_1),\ldots,(v_k,w_k)\}&amp;lt;/math&amp;gt;. This union is a subset of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;, which yields the desired contradiction.&lt;br /&gt;
&lt;br /&gt;
Now we know that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs except one on all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. Note that, for any node not on a cycle, the incoming branching arc may be freely chosen without any effect on the rest. So, since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; agree on all of these choices. Further note that all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; are node-disjoint. In summary, we may compare &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; on each cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; separately.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;, complete agreement between &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; follows from the observation that the choice of incoming arcs for all nodes on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is optimal in &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; due to the specific modification of the arc weights. And for all other cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, complete agreement follows from the induction hypothesis. In both cases, we again used the specific choice of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; to be as close to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; as possible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}((n+m)\cdot n)&amp;lt;/math&amp;gt; in the worst case, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Using [[Depth-first search|DFS]] for cycle detection, each recursive step requires &amp;lt;math&amp;gt;\mathcal{O}(n+m)&amp;lt;/math&amp;gt;. In each shrink operation, the number of nodes decreases, so the recursion depth is &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
More sophisticated implementations of this algorithm yield better asymptotic complexities.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The unshrink operation requires that the shrink operation performs some bookkeeping: For the super-node, a cyclically ordered sequence of all nodes and arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; (or an equivalent bulk of information) must be attached to a super-node.&lt;br /&gt;
# Several cycles may be discovered simultaneously by one run of [[Depth-first search|DFS]]. Note that all cycles in a critical graph are node-disjoint, because no node has more than one incoming arc. Therefore, several cycles may be handled in the same recursive call, without any interference.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2716</id>
		<title>Branching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2716"/>
		<updated>2015-01-02T10:21:00Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Maximum branching]]&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# An arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; is '''critical''' for &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if its weight is not smaller than the weight of any other incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''critical subgraph''' &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains exactly one incoming arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; of positive indegree, where &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is critical.&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' The output of a recursive call is a maximum branching of the weighted graph that was the input for this recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Terminate if &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free, it is a branching. Consider some other branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; does not have more total weight than &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By definition, a critical graph contains one incoming arc for each node that does have incoming arcs. Therefore, for each arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, there is an arc &amp;lt;math&amp;gt;a'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; pointing to the same node. Due to the choice of arcs for &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;w(a)\leq w(a')&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
[[File:Edmonds max branching ani 10000.gif|thumb|350px|''animated gif:'' Branching by Edmonds]]&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Compute a critical subgraph &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; for the input graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Identify some cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; denote the minimum weight of all arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; pointing from some node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;:&lt;br /&gt;
##Decrease the weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;w(v',w)-W\geq 0&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;(v',w)&amp;lt;/math&amp;gt; is the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If the new weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not positive, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Shrink &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; into one new super-node, where every arc pointing to (resp., from)  some node on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; now points to (from) that super-node.&lt;br /&gt;
# Call the algorithm recursively for the modified weighted graph after shrinking, giving branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Unshrink the graph.&lt;br /&gt;
# Add all arcs of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; contains an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;: remove the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;; otherwise, remove one arc with weight &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; be the result in both cases.&lt;br /&gt;
# Return &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; is a branching, so we have to prove that it has maximum weight among all branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; be a maximum branching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that, among all maximum branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; shares as many arcs as possible with &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be a cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; (the case &amp;lt;math&amp;gt;C'=C&amp;lt;/math&amp;gt; not excluded). First we show that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; except one. So, suppose for a contradiction that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; does not contain some of the arcs  of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;, say, &amp;lt;math&amp;gt;(v_1,w_1),\ldots,(v_k,w_k)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;k&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Replacing the incoming arc of any &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and doing nothing else, would not decrease the total weight. Since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;, such a replacement cannot result in a branching anymore. Since the indegrees do not change by that replacement, this means that adding &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; would close a cycle. In other words, there is a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt;. Each path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; must enter &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; at one of the nodes &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; because, otherwise, the node where &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; had two incoming arcs in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;: the incoming arc on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; and the arc over which &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. However, this would imply that there is a cycle in the union of all paths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; plus all arcs of &amp;lt;math&amp;gt;C''&amp;lt;/math&amp;gt; '''not''' in &amp;lt;math&amp;gt;\{(v_1,w_1),\ldots,(v_k,w_k)\}&amp;lt;/math&amp;gt;. This union is a subset of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;, which yields the desired contradiction.&lt;br /&gt;
&lt;br /&gt;
Now we know that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs except one on all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. Note that, for any node not on a cycle, the incoming branching arc may be freely chosen without any effect on the rest. So, since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; agree on all of these choices. Further note that all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; are node-disjoint. In summary, we may compare &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; on each cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; separately.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;, complete agreement between &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; follows from the observation that the choice of incoming arcs for all nodes on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is optimal in &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; due to the specific modification of the arc weights. And for all other cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, complete agreement follows from the induction hypothesis. In both cases, we again used the specific choice of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; to be as close to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; as possible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}((n+m)\cdot n)&amp;lt;/math&amp;gt; in the worst case, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Using [[Depth-first search|DFS]] for cycle detection, each recursive step requires &amp;lt;math&amp;gt;\mathcal{O}(n+m)&amp;lt;/math&amp;gt;. In each shrink operation, the number of nodes decreases, so the recursion depth is &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
More sophisticated implementations of this algorithm yield better asymptotic complexities.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The unshrink operation requires that the shrink operation performs some bookkeeping: For the super-node, a cyclically ordered sequence of all nodes and arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; (or an equivalent bulk of information) must be attached to a super-node.&lt;br /&gt;
# Several cycles may be discovered simultaneously by one run of [[Depth-first search|DFS]]. Note that all cycles in a critical graph are node-disjoint, because no node has more than one incoming arc. Therefore, several cycles may be handled in the same recursive call, without any interference.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2715</id>
		<title>Branching by Edmonds</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2715"/>
		<updated>2015-01-02T10:12:23Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Recursive step */ B -&amp;gt; B'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Maximum branching]]&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# An arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; is '''critical''' for &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if its weight is not smaller than the weight of any other incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# A '''critical subgraph''' &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; contains exactly one incoming arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; of positive indegree, where &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is critical.&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' The output of a recursive call is a maximum branching of the weighted graph that was the input for this recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Terminate if &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
If &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; is cycle-free, it is a branching. Consider some other branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; does not have more total weight than &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By definition, a critical graph contains one incoming arc for each node that does have incoming arcs. Therefore, for each arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;, there is an arc &amp;lt;math&amp;gt;a'&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; pointing to the same node. Due to the choice of arcs for &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;w(a)\leq w(a')&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
[[File:Edmonds max branching ani 10000.gif|thumb|350px|''animated gif:'' Branching by Edmonds]]&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Compute a critical subgraph &amp;lt;math&amp;gt;G'=(V,A')&amp;lt;/math&amp;gt; for the input graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Identify some cycle &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; denote the minimum weight of all arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; pointing from some node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;:&lt;br /&gt;
##Decrease the weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;w(v',w)-W\geq 0&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;(v',w)&amp;lt;/math&amp;gt; is the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;.&lt;br /&gt;
## If the new weight of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not positive, remove &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Shrink &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; into one new super-node, where every arc pointing to (resp., from)  some node on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; now points to (from) that super-node.&lt;br /&gt;
# Call the algorithm recursively for the modified weighted graph after shrinking, giving branching &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Unshrink the graph.&lt;br /&gt;
# Add all arcs of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; contains an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is outside &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;: remove the incoming arc of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;; otherwise, remove one arc with weight &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; be the result in both cases.&lt;br /&gt;
# Return &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Obviously, &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; is a branching, so we have to prove that it has maximum weight among all branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; be a maximum branching in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that, among all maximum branchings in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; shares as many arcs as possible with &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; be a cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; (the case &amp;lt;math&amp;gt;C'=C&amp;lt;/math&amp;gt; not excluded). First we show that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; except one. So, suppose for a contradiction that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; does not contain some of the arcs  of &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;, say, &amp;lt;math&amp;gt;(v_1,w_1),\ldots,(v_k,w_k)&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;k&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Replacing the incoming arc of any &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and doing nothing else, would not decrease the total weight. Since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;, such a replacement cannot result in a branching anymore. Since the indegrees do not change by that replacement, this means that adding &amp;lt;math&amp;gt;(v_i,w_i)&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; would close a cycle. In other words, there is a path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v_i&amp;lt;/math&amp;gt;. Each path &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; must enter &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; at one of the nodes &amp;lt;math&amp;gt;w_j&amp;lt;/math&amp;gt; because, otherwise, the node where &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; had two incoming arcs in &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;: the incoming arc on &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt; and the arc over which &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; enters &amp;lt;math&amp;gt;C'&amp;lt;/math&amp;gt;. However, this would imply that there is a cycle in the union of all paths &amp;lt;math&amp;gt;p_i&amp;lt;/math&amp;gt; plus all arcs of &amp;lt;math&amp;gt;C''&amp;lt;/math&amp;gt; '''not''' in &amp;lt;math&amp;gt;\{(v_1,w_1),\ldots,(v_k,w_k)\}&amp;lt;/math&amp;gt;. This union is a subset of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt;, which yields the desired contradiction.&lt;br /&gt;
&lt;br /&gt;
Now we know that &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; contains all arcs except one on all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;. Note that, for any node not on a cycle, the incoming branching arc may be freely chosen without any effect on the rest. So, since &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; is as close as possible to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; agree on all of these choices. Further note that all cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; are node-disjoint. In summary, we may compare &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B'&amp;lt;/math&amp;gt; on each cycle of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; separately.&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt;, complete agreement between &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; follows from the observation that the choice of incoming arcs for all nodes on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is optimal in &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; due to the specific modification of the arc weights. And for all other cycles of &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;, complete agreement follows from the induction hypothesis. In both cases, we again used the specific choice of &amp;lt;math&amp;gt;B_{\mathrm{opt}}&amp;lt;/math&amp;gt; to be as close to &amp;lt;math&amp;gt;B''&amp;lt;/math&amp;gt; as possible.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}((n+m)\cdot n)&amp;lt;/math&amp;gt; in the worst case, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Using [[Depth-first search|DFS]] for cycle detection, each recursive step requires &amp;lt;math&amp;gt;\mathcal{O}(n+m)&amp;lt;/math&amp;gt;. In each shrink operation, the number of nodes decreases, so the recursion depth is &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
More sophisticated implementations of this algorithm yield better asymptotic complexities.&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
# The unshrink operation requires that the shrink operation performs some bookkeeping: For the super-node, a cyclically ordered sequence of all nodes and arcs on &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; (or an equivalent bulk of information) must be attached to a super-node.&lt;br /&gt;
# Several cycles may be discovered simultaneously by one run of [[Depth-first search|DFS]]. Note that all cycles in a critical graph are node-disjoint, because no node has more than one incoming arc. Therefore, several cycles may be handled in the same recursive call, without any interference.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Classical_eulerian_cycle_algorithm&amp;diff=2714</id>
		<title>Classical eulerian cycle algorithm</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Classical_eulerian_cycle_algorithm&amp;diff=2714"/>
		<updated>2015-01-02T08:10:10Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Correctness */ kleine Einfügung zum Verständnis; Korrektur tail -&amp;gt; beginning node im Beweis&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Nikolaus.png|400px|thumb|right|Another may well know example with 44 solutions]]&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Eulerian cycle]]&lt;br /&gt;
&lt;br /&gt;
''' Type of algorithm:''' recursion with an arbitrarily chosen start node &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt; as an additional input. Before the proper recursive procedure is invoked, the output sequence &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is initialized so as to contain the start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and nothing else.&lt;br /&gt;
&lt;br /&gt;
== Recursion anchor ==&lt;br /&gt;
&lt;br /&gt;
No edges/arcs leave the start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; of that recursive call.&lt;br /&gt;
&lt;br /&gt;
== Recursive step ==&lt;br /&gt;
&lt;br /&gt;
For notational convenience, both undirected edges and directed arcs are denoted by parentheses in the following (in the direction in which they are looked at).&lt;br /&gt;
&lt;br /&gt;
# Let &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; be a (dynamically growing) path, represented in &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as an alternating sequence of nodes and edges/arcs.&lt;br /&gt;
# Initialize &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; so as to contain &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and nothing else.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;x:=s&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While there are edges/arcs leaving &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;:&lt;br /&gt;
## Choose one such arc &amp;lt;math&amp;gt;(x,y)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Remove &amp;lt;math&amp;gt;(x,y)&amp;lt;/math&amp;gt; from the graph.&lt;br /&gt;
## Append &amp;lt;math&amp;gt;(x,y)&amp;lt;/math&amp;gt; and then &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;x:=y&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;x\neq s&amp;lt;/math&amp;gt;, terminate the algorithm with the statement that no eulerian cycle exists.&lt;br /&gt;
# Otherwise: For each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; that still has leaving edges/arcs,:&lt;br /&gt;
## Call the procedure recursively with &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as the start node, giving path &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Replace &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Since each edge/arc is removed immediately when it is processed, no edge/arc occurs twice in the output. Obviously, steps 4.3 and 6.2 ensure that the order in which the nodes and edges/arcs occur in the output yields a correct path. Obviously, whenever step 4 is finished, it is &amp;lt;math&amp;gt;x=s&amp;lt;/math&amp;gt; and the remaining graph is eulerian, if the original graph was eulerian. Consequently, the statement that no eulerian cycle exists is only delivered if the graph is indeed non-eulerian. Moreover, the graph handed over to a recursive call is Eulerian, if the original graph was Eulerian.&lt;br /&gt;
&lt;br /&gt;
Suppose for a contradiction that some edge/arc &amp;lt;math&amp;gt;e/a&amp;lt;/math&amp;gt; is '''not''' in the output. Since the graph is (strongly) connected, there is a path &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; from the start node of the algorithm to the beginning node of &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; (an arbitrary endnode of &amp;lt;math&amp;gt;e&amp;lt;/math&amp;gt; in the undirected case). Let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be the last node on &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; processed by any recursive call. Then the subsequent edge/arc on &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; has not been processed, which contradicts the procedure.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
Both for directed and undirected graphs, the asymtptotic complexity is linear in the number of edges/ars.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
We assume that all data structures are implemented in the obvious appropriate way. First note that steps 1, 2, 3, and 5 take constant time each. So the total complexity of these steps is linear in the number of recursive calls, which is linear in the number of edges/arcs in turn. The total number of iterations of steps 4 and 6, respectively, taken over all recursive calls, is linear in the number of edges/arcs as well.&lt;br /&gt;
&lt;br /&gt;
'''Remarks:'''&lt;br /&gt;
# Since the graph is (strongly) connected, the number of nodes is asymptotically dominated by the number of edges/arcs and, therefore, irrelevant here.&lt;br /&gt;
# Of course, the edges/arcs need not be removed permanently. However, when an edge/arc is processed, it must be hidden from the algorithm up to its termination to achieve the linear bound on the complexity. A boolean edge/arc label to indicate whether this edge/arc has already been processed, does not suffice.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:Eulerpath_1.png|Step 1&lt;br /&gt;
File:Eulerpath_2.png|Step 2&lt;br /&gt;
File:Eulerpath_3.png|Step 3&lt;br /&gt;
File:Eulerpath_4.png|Step 4&lt;br /&gt;
File:Eulerpath_5.png|Step 5&lt;br /&gt;
File:Eulerpath_6.png|Step 6&lt;br /&gt;
File:Eulerpath_7.png|Step 7&lt;br /&gt;
File:Eulerpath_8.png|Step 8&lt;br /&gt;
File:Eulerpath_9.png|Step 9&lt;br /&gt;
File:Eulerpath_10.png|Step 10&lt;br /&gt;
File:Eulerpath_11.png|Final Step&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2713</id>
		<title>Hopcroft-Tarjan</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2713"/>
		<updated>2015-01-01T17:43:47Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Step 2 */ Behandlung von besonderen Artikulationsknoten&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Biconnected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
two steps.&lt;br /&gt;
&lt;br /&gt;
== Step 1 ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# A start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and an edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; to an arbitrarily chosen node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; are added to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The core algorithm is a variation of [[Depth-first search|DFS]], where for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; two additional nonnegative integral numbers are computed:&lt;br /&gt;
## The '''depth''' of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence created by the DFS procedure.&lt;br /&gt;
## The '''lowpoint''', that is the minimal depth of any node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;\{u,w\}\in E&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; or an immediate or non-immediate successor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the DFS tree.&lt;br /&gt;
# The start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and the edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and from the DFS arborescence (which is rooted at &amp;lt;matH&amp;gt;v&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
'''Implementation of step 1:'''&lt;br /&gt;
# ''Depth'': The DFS maintains a global integral number, the '''current depth'''. Whenever a node is seen for the first time, its depth attribute is set identical to the current depth. In each forward step, the current depth is ''in''creased by one, in each backward step, it is ''de''creased by one.&lt;br /&gt;
# ''Lowpoint'':&lt;br /&gt;
## Whenever a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is seen for the first time, its lowpoint is set identical to its depth.&lt;br /&gt;
## Whenever an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is examined such that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; has already been seen and the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
## In each backward step of DFS from a node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; back to its immediate predecessor &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;: If the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remarks:'''&lt;br /&gt;
# We do not choose a start node from the given nodes but insert a new start node to avoid a special treatment of the start node.&lt;br /&gt;
# This is another example where it makes perfect sense to implement graph traversal algorithms as iterators (cf. [[Graph traversal#Remarks|here]]). In fact, then the operations on the depth and lowpoint attributes can be inserted in the DFS loop in an easy, obvious way.&lt;br /&gt;
&lt;br /&gt;
== Step 2 ==&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
A node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''essential''' if, for at least one arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the arborescence from step 1, the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
A repeated application of a modified [[Depth-first search|DFS]] (going only along that outgoing arc of the start node, that leads to the first seen successor, then as usual) in the [[Depth-first search|DFS]] [[Basic graph definitions#Forests, trees, branchings, arborescences|arborescence]] of step 1, where the start nodes of the individual DFS runs are the essential nodes. In that, the essential nodes are considered in ascending order of their finishing times as computed in step 1. The nodes hit in one DFS run (except for the essential start node if it has further outgoing arcs in the initial [[Depth-first search|DFS]] [[Basic graph definitions#Forests, trees, branchings, arborescences|arborescence]] of step 1) and all of their [[Basic graph definitions#Adjacency, incidence, and degree|incident]] edges are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; before the next DFS run commences. The node sets visited in the individual DFS runs are returned as the biconnected components.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
We do not remove the essential start node after a [[Depth-first search|DFS]] run if it has further outgoing arcs in the initial [[Depth-first search|DFS]] [[Basic graph definitions#Forests, trees, branchings, arborescences|arborescence]] of step 1, because these nodes belong to another [[Basic graph definitions#Connectedness|biconnected component]] as well (not only to the [[Basic graph definitions#Connectedness|biconnected component]] which was traversed by the latest [[Depth-first search|DFS]] run), which means they are always [[Basic graph definitions#Connectedness|articulation nodes]] (but not the other way around).&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Obviously, the depth and the lowpoint are set correctly according to their intended semantics.&lt;br /&gt;
&lt;br /&gt;
First consider an essential node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; be an arc in the arborescence such that the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. We have to show that the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; only. So suppose for a contradiction that there is an edge &amp;lt;math&amp;gt;\{x,y\}&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; belongs to that subarborescence and &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; does not. Then &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; must have been seen before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, because otherwise, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; would be in the subarborescence rooted at &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. Since the lowpoint of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; cannot be a predecessor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence. Hence, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was even finished before &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; was seen. In particular, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was finished before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; was seen, which is impossible.&lt;br /&gt;
&lt;br /&gt;
Now consider a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; that is ''not'' essential. Opposite to the first case, we have to show that the subarborescence rooted at an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not only connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. However, this follows immediately from the definition of the lowpoint value: There is some &amp;lt;math&amp;gt;x\in V&amp;lt;/math&amp;gt; in the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; connected to some node &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; that cannot be in the subarborescence due to its smaller depth.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is linear.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Follows immediately from the linear asymptotic complexity of DFS.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2712</id>
		<title>Hopcroft-Tarjan</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2712"/>
		<updated>2015-01-01T17:31:41Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Step 2 */  Behandlung von besonderen Artikulationsknoten&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Biconnected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
two steps.&lt;br /&gt;
&lt;br /&gt;
== Step 1 ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# A start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and an edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; to an arbitrarily chosen node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; are added to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The core algorithm is a variation of [[Depth-first search|DFS]], where for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; two additional nonnegative integral numbers are computed:&lt;br /&gt;
## The '''depth''' of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence created by the DFS procedure.&lt;br /&gt;
## The '''lowpoint''', that is the minimal depth of any node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;\{u,w\}\in E&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; or an immediate or non-immediate successor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the DFS tree.&lt;br /&gt;
# The start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and the edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and from the DFS arborescence (which is rooted at &amp;lt;matH&amp;gt;v&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
'''Implementation of step 1:'''&lt;br /&gt;
# ''Depth'': The DFS maintains a global integral number, the '''current depth'''. Whenever a node is seen for the first time, its depth attribute is set identical to the current depth. In each forward step, the current depth is ''in''creased by one, in each backward step, it is ''de''creased by one.&lt;br /&gt;
# ''Lowpoint'':&lt;br /&gt;
## Whenever a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is seen for the first time, its lowpoint is set identical to its depth.&lt;br /&gt;
## Whenever an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is examined such that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; has already been seen and the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
## In each backward step of DFS from a node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; back to its immediate predecessor &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;: If the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remarks:'''&lt;br /&gt;
# We do not choose a start node from the given nodes but insert a new start node to avoid a special treatment of the start node.&lt;br /&gt;
# This is another example where it makes perfect sense to implement graph traversal algorithms as iterators (cf. [[Graph traversal#Remarks|here]]). In fact, then the operations on the depth and lowpoint attributes can be inserted in the DFS loop in an easy, obvious way.&lt;br /&gt;
&lt;br /&gt;
== Step 2 ==&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
A node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''essential''' if, for at least one arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the arborescence from step 1, the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
A repeated application of [[Depth-first search|DFS]], where the start nodes of the individual DFS runs are the essential nodes. In that, the essential nodes are considered in ascending order of their finishing times as computed in step 1. The nodes hit in one DFS run (except for the essential start node if it has further outgoing arcs in the initial [[Depth-first search|DFS]] [[Basic graph definitions#Forests, trees, branchings, arborescences|arborescence]] of step 1) and all of their [[Basic graph definitions#Adjacency, incidence, and degree|incident]] edges are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; before the next DFS run commences. The node sets visited in the individual DFS runs are returned as the biconnected components.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
We do not remove the essential start node after a [[Depth-first search|DFS]] run if it has further outgoing arcs in the initial [[Depth-first search|DFS]] [[Basic graph definitions#Forests, trees, branchings, arborescences|arborescence]] of step 1, because these nodes belong to another [[Basic graph definitions#Connectedness|biconnected component]] as well (not only to the [[Basic graph definitions#Connectedness|biconnected component]] which was traversed by the latest [[Depth-first search|DFS]] run), which means they are always [[Basic graph definitions#Connectedness|articulation nodes]] (but not the other way around).&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Obviously, the depth and the lowpoint are set correctly according to their intended semantics.&lt;br /&gt;
&lt;br /&gt;
First consider an essential node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; be an arc in the arborescence such that the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. We have to show that the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; only. So suppose for a contradiction that there is an edge &amp;lt;math&amp;gt;\{x,y\}&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; belongs to that subarborescence and &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; does not. Then &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; must have been seen before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, because otherwise, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; would be in the subarborescence rooted at &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. Since the lowpoint of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; cannot be a predecessor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence. Hence, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was even finished before &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; was seen. In particular, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was finished before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; was seen, which is impossible.&lt;br /&gt;
&lt;br /&gt;
Now consider a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; that is ''not'' essential. Opposite to the first case, we have to show that the subarborescence rooted at an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not only connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. However, this follows immediately from the definition of the lowpoint value: There is some &amp;lt;math&amp;gt;x\in V&amp;lt;/math&amp;gt; in the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; connected to some node &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; that cannot be in the subarborescence due to its smaller depth.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is linear.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Follows immediately from the linear asymptotic complexity of DFS.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2711</id>
		<title>Hopcroft-Tarjan</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2711"/>
		<updated>2015-01-01T16:36:25Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Step 1 */  Berichtigung der Definition von &amp;quot;lowpoint&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Biconnected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
two steps.&lt;br /&gt;
&lt;br /&gt;
== Step 1 ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# A start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and an edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; to an arbitrarily chosen node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; are added to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The core algorithm is a variation of [[Depth-first search|DFS]], where for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; two additional nonnegative integral numbers are computed:&lt;br /&gt;
## The '''depth''' of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence created by the DFS procedure.&lt;br /&gt;
## The '''lowpoint''', that is the minimal depth of any node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;\{u,w\}\in E&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; or an immediate or non-immediate successor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the DFS tree.&lt;br /&gt;
# The start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and the edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and from the DFS arborescence (which is rooted at &amp;lt;matH&amp;gt;v&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
'''Implementation of step 1:'''&lt;br /&gt;
# ''Depth'': The DFS maintains a global integral number, the '''current depth'''. Whenever a node is seen for the first time, its depth attribute is set identical to the current depth. In each forward step, the current depth is ''in''creased by one, in each backward step, it is ''de''creased by one.&lt;br /&gt;
# ''Lowpoint'':&lt;br /&gt;
## Whenever a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is seen for the first time, its lowpoint is set identical to its depth.&lt;br /&gt;
## Whenever an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is examined such that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; has already been seen and the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
## In each backward step of DFS from a node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; back to its immediate predecessor &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;: If the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remarks:'''&lt;br /&gt;
# We do not choose a start node from the given nodes but insert a new start node to avoid a special treatment of the start node.&lt;br /&gt;
# This is another example where it makes perfect sense to implement graph traversal algorithms as iterators (cf. [[Graph traversal#Remarks|here]]). In fact, then the operations on the depth and lowpoint attributes can be inserted in the DFS loop in an easy, obvious way.&lt;br /&gt;
&lt;br /&gt;
== Step 2 ==&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
A node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''essential''' if, for at least one arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the arborescence from step 1, the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
A repeated application of [[Depth-first search|DFS]], where the start nodes of the individual DFS runs are the essential nodes. In that, the essential nodes are considered in ascending order of their finishing times as computed in step 1. The nodes hit in one DFS run are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; before the next DFS run commences. The node sets visited in the individual DFS runs are returned as the biconnected components.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Obviously, the depth and the lowpoint are set correctly according to their intended semantics.&lt;br /&gt;
&lt;br /&gt;
First consider an essential node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; be an arc in the arborescence such that the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. We have to show that the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; only. So suppose for a contradiction that there is an edge &amp;lt;math&amp;gt;\{x,y\}&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; belongs to that subarborescence and &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; does not. Then &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; must have been seen before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, because otherwise, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; would be in the subarborescence rooted at &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. Since the lowpoint of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; cannot be a predecessor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence. Hence, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was even finished before &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; was seen. In particular, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was finished before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; was seen, which is impossible.&lt;br /&gt;
&lt;br /&gt;
Now consider a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; that is ''not'' essential. Opposite to the first case, we have to show that the subarborescence rooted at an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not only connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. However, this follows immediately from the definition of the lowpoint value: There is some &amp;lt;math&amp;gt;x\in V&amp;lt;/math&amp;gt; in the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; connected to some node &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; that cannot be in the subarborescence due to its smaller depth.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is linear.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Follows immediately from the linear asymptotic complexity of DFS.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=2710</id>
		<title>Kosaraju</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=2710"/>
		<updated>2014-12-30T14:40:34Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Correctness */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Strongly connected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
== Abstract View ==&lt;br /&gt;
&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, the output order is parenthetical.&lt;br /&gt;
# Invert the output order of the nodes.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G^t=(V,A^t)&amp;lt;/math&amp;gt; be the [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G^t&amp;lt;/math&amp;gt; with a modification: The order in which the nodes are considered as potential start nodes is the inverted parenthetical order from step 2. &lt;br /&gt;
# The node sets from the individual applications of [[Depth-first search|DFS]] inside step 4 are exactly the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
First note that the transposition of all arcs does not change the SCC of a graph, so step 4 indeed processes the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
[[File:CondensedGraphKosaraju.jpg|200px|thumb|right|Construction of the condensed graph (example)]]&lt;br /&gt;
Consider the condensed graph &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; whose nodes are these SCC, and there is an arc from an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; if, and only if, there is at least one arc in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; from some node in &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to some node in &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt;. This condensed graph is acyclic because all nodes in all SCC on a cycle would be mutually reachable from each other in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and their union would consequently form a single larger SCC contradicting the construction of the condensed graph.&lt;br /&gt;
&lt;br /&gt;
In step 1, each [[Depth-first search|DFS]] run either meets ''all'' nodes of an SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; or ''none'' of the nodes of this SCC. More specifically, all nodes in the same SCC as the start node and in all SCC reachable from that SCC, except for the SCC processed in previous [[Depth-first search|DFS]] runs.&lt;br /&gt;
&lt;br /&gt;
Due to the parenthetical order of the [[Depth-first search|DFS]], if an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, then there is at least one node of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; which appears after all nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in the output sequence of step 1 (because it is finished in [[Depth-first search|DFS]] after the nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt;). Equivalently, there is at least one node of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; which appears before all nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in the reverse order of step 2 on which step 4 is based.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j (i \neq j)&amp;lt;/math&amp;gt; be two SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Since each SCC is processed exhaustively or not at all in a  [[Depth-first search|DFS]] run, it suffices to show that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are not processed within the same run of step 4. Suppose for a contradiction that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are processed in the same [[Depth-first search|DFS]] run in step 4 (not necessarily in the same run in step 1). Let &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; be the SCC which the start node of that run in step 4 belongs to (possibly &amp;lt;math&amp;gt;k=i&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;k=j&amp;lt;/math&amp;gt;). Without loss of generality, suppose &amp;lt;math&amp;gt;k\neq i&amp;lt;/math&amp;gt;. Then &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G^t&amp;lt;/math&amp;gt;; in other words, &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. However, then at least one node of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; had had a higher finishing time in step 1 than the nodes of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;, so it had been chosen as a start node in step 4 before any node of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; and the whole SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; had been seen in the [[Depth-first search|DFS]] run from this node which contradicts the assumption that it is seen in a [[Depth-first search|DFS]] run from a node of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The asymptotic complexity is in &amp;lt;math&amp;gt;\Theta(|V|+|A|)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Follows immediately from the linear asymptotic complexity of [[Repeated depth-first search|repeated DFS]].&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 STRONGLY-CONNECTED-COMPONENTS(''D'')&lt;br /&gt;
 1 call '''DFS'''(''D'') to compute finishing times ''f''[v] for each vertex ''v'' &amp;amp;isin; ''V''&lt;br /&gt;
 2 compute ''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt; (w.r.t. step 3)&lt;br /&gt;
 3 call '''DFS'''(''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt;), but in the main loop of '''DFS''', consider the vertices in order of decreasing ''f''[v] as computed in step 1&lt;br /&gt;
 4 output the vertices of each tree in the '''DFS''' forest of step 3 as a separate strongly connected component&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=2709</id>
		<title>Kosaraju</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=2709"/>
		<updated>2014-12-30T14:19:59Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Correctness */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Strongly connected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
== Abstract View ==&lt;br /&gt;
&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, the output order is parenthetical.&lt;br /&gt;
# Invert the output order of the nodes.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G^t=(V,A^t)&amp;lt;/math&amp;gt; be the [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G^t&amp;lt;/math&amp;gt; with a modification: The order in which the nodes are considered as potential start nodes is the inverted parenthetical order from step 2. &lt;br /&gt;
# The node sets from the individual applications of [[Depth-first search|DFS]] inside step 4 are exactly the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
First note that the transposition of all arcs does not change the SCC of a graph, so step 4 indeed processes the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
[[File:CondensedGraphKosaraju.jpg|200px|thumb|right|Construction of the condensed graph (example)]]&lt;br /&gt;
Consider the condensed graph &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; whose nodes are these SCC, and there is an arc from an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; if, and only if, there is at least one arc in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; from some node in &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to some node in &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt;. This condensed graph is acyclic because all nodes in all SCC on a cycle would be mutually reachable from each other in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and their union would consequently form a single larger SCC contradicting the construction of the condensed graph.&lt;br /&gt;
&lt;br /&gt;
In step 1, each [[Depth-first search|DFS]] run either meets ''all'' nodes of an SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; or ''none'' of the nodes of this SCC. More specifically, all nodes in the same SCC as the start node and in all SCC reachable from that SCC, except for the SCC processed in previous [[Depth-first search|DFS]] runs.&lt;br /&gt;
&lt;br /&gt;
Due to the parenthetical order of the [[Depth-first search|DFS]], if an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, then there is at least one node of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; which appears after all nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in the output sequence of step 1 (because it is finished in [[Depth-first search|DFS]] after the nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt;). Equivalently, there is at least one node of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; which appears before all nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in the reverse order of step 2 on which step 4 is based.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; be two SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Since each SCC is processed exhaustively or not at all in a  [[Depth-first search|DFS]] run, it suffices to show that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are not processed within the same run of step 4. Suppose for a contradiction that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are processed in the same [[Depth-first search|DFS]] run in step 4 (not necessarily in the same run in step 1). Let &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; be the SCC to which the start node of that run belongs (possibly &amp;lt;math&amp;gt;k=i&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;k=j&amp;lt;/math&amp;gt;). Without loss of generality, suppose &amp;lt;math&amp;gt;k\neq i&amp;lt;/math&amp;gt;. Then &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;; in other words, &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. However, then the nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; have higher finishing times than the nodes of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;, so some node of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; had been chosen as a start node before any node of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The asymptotic complexity is in &amp;lt;math&amp;gt;\Theta(|V|+|A|)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Follows immediately from the linear asymptotic complexity of [[Repeated depth-first search|repeated DFS]].&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 STRONGLY-CONNECTED-COMPONENTS(''D'')&lt;br /&gt;
 1 call '''DFS'''(''D'') to compute finishing times ''f''[v] for each vertex ''v'' &amp;amp;isin; ''V''&lt;br /&gt;
 2 compute ''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt; (w.r.t. step 3)&lt;br /&gt;
 3 call '''DFS'''(''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt;), but in the main loop of '''DFS''', consider the vertices in order of decreasing ''f''[v] as computed in step 1&lt;br /&gt;
 4 output the vertices of each tree in the '''DFS''' forest of step 3 as a separate strongly connected component&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=2708</id>
		<title>Kosaraju</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=2708"/>
		<updated>2014-12-30T14:17:55Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Correctness */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Strongly connected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
== Abstract View ==&lt;br /&gt;
&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, the output order is parenthetical.&lt;br /&gt;
# Invert the output order of the nodes.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G^t=(V,A^t)&amp;lt;/math&amp;gt; be the [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G^t&amp;lt;/math&amp;gt; with a modification: The order in which the nodes are considered as potential start nodes is the inverted parenthetical order from step 2. &lt;br /&gt;
# The node sets from the individual applications of [[Depth-first search|DFS]] inside step 4 are exactly the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
First note that the transposition of all arcs does not change the SCC of a graph, so step 4 indeed processes the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
[[File:CondensedGraphKosaraju.jpg|200px|thumb|right|Construction of the condensed graph (example)]]&lt;br /&gt;
Consider the condensed graph &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; whose nodes are these SCC, and there is an arc from an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; if, and only if, there is at least one arc in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; from some node in &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to some node in &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt;. This condensed graph is acyclic because all nodes in all SCC on a cycle would be mutually reachable from each other in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and their union would consequently form a single larger SCC contradicting the construction of the condensed graph.&lt;br /&gt;
&lt;br /&gt;
In step 1, each [[Depth-first search|DFS]] run either meets ''all'' nodes of an SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; or ''none'' of the nodes of this SCC. More specifically, all nodes in the same SCC as the start node and in all SCC reachable from that SCC, except for the SCC processed in previous [[Depth-first search|DFS]] runs.&lt;br /&gt;
&lt;br /&gt;
Due to the parenthetical order of the [[Depth-first search|DFS]], if an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, then there is at least one node of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; which appears after all nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in the output sequence of step 1. Equivalently, there is at least one node of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; which appears before all nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in the reverse order of step 2 on which step 4 is based.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; be two SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Since each SCC is processed exhaustively or not at all in a  [[Depth-first search|DFS]] run, it suffices to show that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are not processed within the same run of step 4. Suppose for a contradiction that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are processed in the same [[Depth-first search|DFS]] run in step 4 (not necessarily in the same run in step 1). Let &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; be the SCC to which the start node of that run belongs (possibly &amp;lt;math&amp;gt;k=i&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;k=j&amp;lt;/math&amp;gt;). Without loss of generality, suppose &amp;lt;math&amp;gt;k\neq i&amp;lt;/math&amp;gt;. Then &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;; in other words, &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. However, then the nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; have higher finishing times than the nodes of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;, so some node of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; had been chosen as a start node before any node of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The asymptotic complexity is in &amp;lt;math&amp;gt;\Theta(|V|+|A|)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Follows immediately from the linear asymptotic complexity of [[Repeated depth-first search|repeated DFS]].&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 STRONGLY-CONNECTED-COMPONENTS(''D'')&lt;br /&gt;
 1 call '''DFS'''(''D'') to compute finishing times ''f''[v] for each vertex ''v'' &amp;amp;isin; ''V''&lt;br /&gt;
 2 compute ''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt; (w.r.t. step 3)&lt;br /&gt;
 3 call '''DFS'''(''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt;), but in the main loop of '''DFS''', consider the vertices in order of decreasing ''f''[v] as computed in step 1&lt;br /&gt;
 4 output the vertices of each tree in the '''DFS''' forest of step 3 as a separate strongly connected component&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Depth-first_search&amp;diff=2707</id>
		<title>Depth-first search</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Depth-first_search&amp;diff=2707"/>
		<updated>2014-12-30T09:55:17Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Abstract view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Algorithms]]&lt;br /&gt;
[[Category:Search Algorithms]]&lt;br /&gt;
[[Category:Tree Algorithms]]&lt;br /&gt;
[[Category:Graph Traversal]]&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Graph traversal]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
== Definitions ==&lt;br /&gt;
# For each node, an arbitrary but fixed ordering of the outgoing arcs is assumed. An arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; preceding an arc &amp;lt;math&amp;gt;(v,w')&amp;lt;/math&amp;gt; in this ordering is called '''lexicographically smaller''' than &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; be two paths that start from the same node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;, but may or may not have the same end node. Let &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; be the last common node such that the subpaths of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; up to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; are identical (possibly &amp;lt;math&amp;gt;v=w&amp;lt;/math&amp;gt;). If the next arc of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; onwards is lexicographically smaller than the next arc of &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; onwards, &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is said to be '''lexicograpically smaller''' than &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt;. Note that the lexicographically ''smallest'' path from &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; is well defined and unique.&lt;br /&gt;
# With respect to a starting node &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt;, a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''lexicographically smaller''' than &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; if the lexicographically smallest path from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is lexicographically smaller than the lexicographically smallest path from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
# In all of the above cases, the reverse relation is called '''lexicographically larger'''.&lt;br /&gt;
# A node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''lexicographically smaller''' (resp., '''lexicograpically larger''') than a path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; does not belong to &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; and the lexicographically smallest path from the start node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is lexicographically smaller (resp., larger) than &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. (Note the asymmetry: In both cases, the lexicographically ''smallest'' path to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is used.)&lt;br /&gt;
# In all cases, we also say '''precedes''' and '''succeeds''', respectively, instead of &amp;quot;is lexicograpically smaller/larger&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Additional output:'''&lt;br /&gt;
# Each node has two Boolean labels with semantics, &amp;quot;is seen&amp;quot; and &amp;quot;is finished&amp;quot;.&lt;br /&gt;
# An [[Basic graph definitions#Forests, trees, branchings, arborescences|arborescence]] &amp;lt;math&amp;gt;A=(V',A')&amp;lt;/math&amp;gt; rooted at &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;V'\subseteq V&amp;lt;/math&amp;gt; is the set of all nodes reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; (including &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;). For each node &amp;lt;math&amp;gt;v\in V'&amp;lt;/math&amp;gt;, the path from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; is the lexicographically smallest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Specific characteristic:'''&lt;br /&gt;
The nodes may be returned either in lexicographic order or (alternatively or simultaneously) in '''parenthetical order''', that is:&lt;br /&gt;
Let &amp;lt;math&amp;gt;v,w\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is seen before &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;. If there is a path from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is finished prior to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
''Parenthetical'' refers to the following intuition: Whenever a node is seen, open a parenthesis, and close it once the node is finished. The result is a correct parenthetial expression: Two parentheses are either disjoint, or one is nested in the other one.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A [[Sets and sequences#Stacks and queues|stack]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; whose elements are nodes in &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node  has a '''current arc''' &amp;lt;math&amp;gt;a_v\in V&amp;lt;/math&amp;gt;, which is either void or an outgoing arc &amp;lt;math&amp;gt;a_v=(v,w)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. (May be viewed as an iterator over the list of all outgoing arcs.)&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' &lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; forms a path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to some other node, that is, the order of the nodes on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is the order in which they appear in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; (start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; at the bottom of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;).&lt;br /&gt;
# For each node not yet seen, the current arc is the first arc (or void if the node has no outgoing arcs).&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;:&lt;br /&gt;
## If there are arcs &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is not yet seen, the current arc equals or precedes the first such arc.&lt;br /&gt;
## The subpath of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; from the start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is the lexicographically first &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path.&lt;br /&gt;
# The nodes on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; are seen but not finished. Let &amp;lt;math&amp;gt;p+a&amp;lt;/math&amp;gt; denote the concatenation of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with the current arc &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; of the last node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. The nodes that are lexicographically smaller than &amp;lt;math&amp;gt;p+a&amp;lt;/math&amp;gt; are seen and finished, and the nodes that lexicographically succeed &amp;lt;math&amp;gt;p+a&amp;lt;/math&amp;gt; are neither seen nor finished. (Note that nothing is said about the head of &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
'''Variant:''' Either one node is finished or the current arc of one node is moved forward.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:''' &amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' No node is finished. The start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is seen, no other node is seen. The start node is the only element of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;. The current arc of each node is its first outgoing arc. If the nodes are to be returned in lexicographic order, the start node &amp;lt;math&amp;gt;&amp;lt;/math&amp;gt; is, initially, the only member of the output sequence; otherwise, the initial output sequence is empty. Arborescence &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; is initialized so as to contain &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and nothing else.&lt;br /&gt;
&lt;br /&gt;
'''Implementation:''' Obvious.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Obvious.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be the last node of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; (=the top element of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;).&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and while the head of the current arc is labeled as seen: Move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void, say, &amp;lt;math&amp;gt;a_v=(v,w)&amp;lt;/math&amp;gt;:&lt;br /&gt;
## Insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Push &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Label &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; as seen.&lt;br /&gt;
## If the output order is the lexicographical one: Append &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to the output sequence.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Remove &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;&lt;br /&gt;
## Label &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; as finished.&lt;br /&gt;
## If the output order is the parenthetical one: Put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the output sequence.&lt;br /&gt;
&lt;br /&gt;
'''Implementation:''' Obvious.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
The loop ''variant'' is obviously fulfilled.&lt;br /&gt;
&lt;br /&gt;
The first point of the ''invariant'' is obviously fulfilled, too. The second point follows from the fact that the current arc of a node is initialized to be the node's very first outgoing arc and only changed after the node is labeled as ''seen''. Point 3.1 follows from the fact that, in step 2, the current arc never skips an arc that points to an unseen node.&lt;br /&gt;
&lt;br /&gt;
For point 3.2, let &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; be the lexicographically smallest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path. Moreover, let &amp;lt;math&amp;gt;w\neq v&amp;lt;/math&amp;gt; be the last node on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; such that both paths are identical from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; (possibly, &amp;lt;math&amp;gt;w=s&amp;lt;/math&amp;gt;). Further, let &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u'&amp;lt;/math&amp;gt; be the immediate successors of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt;, respectively. Then &amp;lt;math&amp;gt;u'&amp;lt;/math&amp;gt; has been seen before &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; because &amp;lt;math&amp;gt;(w,u)&amp;lt;/math&amp;gt; is the arc over which &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; was seen for the first time, and &amp;lt;math&amp;gt;(w,u')&amp;lt;/math&amp;gt; precedes &amp;lt;math&amp;gt;(w,u)&amp;lt;/math&amp;gt;. Note that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has not been seen earlier than &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; (in fact, later than &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt;, unless &amp;lt;math&amp;gt;v=u&amp;lt;/math&amp;gt;). In summary, &amp;lt;math&amp;gt;u'&amp;lt;/math&amp;gt; has been seen before &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. Since there is a path from &amp;lt;math&amp;gt;u'&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the correctness proof [[#Correctness|below]] will prove that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; was finished before &amp;lt;math&amp;gt;u'&amp;lt;/math&amp;gt;. This contradicts the induction hypothesis (point 4 of the invariant).&lt;br /&gt;
&lt;br /&gt;
When a node is pushed on &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, it is neither seen nor finished immediately before that iteration and then labeled as seen in that iteration. The node is finished when it leaves &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;. Both facts together give the first sentence of point 4. The other statements of point 4 follow from the observation that the concatenation of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with the current arc of the endnode of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; increases lexicographically in each iteration.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
It is easy to see that each operation of the algorithm is well defined. Due to the variant, the loop terminates after a finite number of steps. Immediately before the last iteration, &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; consists of the start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; only, and the current arc of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is void. Therefore, ''all'' nodes reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; except for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; itself are lexicographically smaller than &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; at that moment. Due to point 4 of the invariant, all of these nodes are finished. In the last iteration, &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is finished as well.&lt;br /&gt;
&lt;br /&gt;
So, it remains to show that the specific characteristic is fulfilled in both cases.&lt;br /&gt;
Due to point 3.2 of the invariant, a node is seen for the first time via its lexicographically smallest path from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. Since the current path increases lexicographically in each iteration, the nodes are labeled as seen in lexicographic order. In summary, the lexicographical order is correct.&lt;br /&gt;
&lt;br /&gt;
So consider the second, the parenthetical case.&lt;br /&gt;
Let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be seen before &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; and assume there is a path from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;. We have to show that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is finished prior to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;p'&amp;lt;/math&amp;gt; denote the lexicographically smallest &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;-path. There is a stage in which this path is a subpath of the current path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Clearly, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; cannot be removed from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; before &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The asymptotic complexity is in &amp;lt;math&amp;gt;\Theta(|V|+|A|)&amp;lt;/math&amp;gt; in the worst case.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For every node reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; (including &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;), the algorithm processes each of its outgoing arcs exactly once. And from each of these nodes, the algorithm goes backwards exactly once. Obviously, each of these steps requires a constant number of operations.&lt;br /&gt;
&lt;br /&gt;
== Remark ==&lt;br /&gt;
&lt;br /&gt;
Alternatively, DFS could be implemented as a recursive procedure. However, this excludes the option to implement DFS as an iterator, which means to turn the loop inside-out (cf. remarks on [[Graph traversal|graph traversal]]).&lt;br /&gt;
&lt;br /&gt;
== Pseudocode recursive implementation == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== DFS(''G'') ====&lt;br /&gt;
:'''for''' each vertex ''u'' &amp;amp;isin; ''V'' [''G''] &lt;br /&gt;
::'''do''' color[''u''] &amp;amp;larr; WHITE&lt;br /&gt;
::: ''&amp;amp;pi;''[''u''] &amp;amp;larr; NIL&lt;br /&gt;
:''time'' &amp;amp;larr; 0&lt;br /&gt;
:: '''do if''' ''color''[''u''] == WHITE&lt;br /&gt;
::: '''then''' DFS-VISiT(''u'')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DFS-VISIT(''u'')====&lt;br /&gt;
: ''color''[''u''] &amp;amp;larr; GRAY   &lt;br /&gt;
: ''time'' &amp;amp;larr; ''time'' + 1&lt;br /&gt;
: ''d''[''u''] &amp;amp;larr; ''time''&lt;br /&gt;
: '''for''' each ''v'' &amp;amp;isin; ''Adj''[''u'']&lt;br /&gt;
:: '''do if''' ''color''[''v''] = WHITE&lt;br /&gt;
::: ''' then ''' &amp;amp;pi; [''v''] &amp;amp;larr; ''u''&lt;br /&gt;
:::: DFS-VISIT(''v'')&lt;br /&gt;
:''color''[''u''] &amp;amp;larr; BLACK&lt;br /&gt;
:''f''[''u''] &amp;amp;larr; ''time'' &amp;amp;larr; ''time'' + 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pseudocode stack implementation ==&lt;br /&gt;
&lt;br /&gt;
====DFS(''s'')====&lt;br /&gt;
: ''S = new Stack()''&lt;br /&gt;
: ''s.IsSeen = true''&lt;br /&gt;
: ''S.push(s)''&lt;br /&gt;
: '''while''' ''S'' &amp;amp;ne; &amp;amp;empty;&lt;br /&gt;
:: ''n'' = ''S.peek()''&lt;br /&gt;
:: ''a'' = ''(v, w)'' = ''n.nextArc()''&lt;br /&gt;
:: '''if''' ''a'' == ''null''&lt;br /&gt;
::: ''n.IsFinised'' = ''true''&lt;br /&gt;
::: ''S.pop()''&lt;br /&gt;
:: '''else if''' ''w.IsSeen'' == ''false''&lt;br /&gt;
::: ''w.IsSeen'' = ''true''&lt;br /&gt;
::: ''S.push(w)''&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Bounded_priority_queue&amp;diff=2706</id>
		<title>Bounded priority queue</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Bounded_priority_queue&amp;diff=2706"/>
		<updated>2014-12-28T14:17:35Z</updated>

		<summary type="html">&lt;p&gt;BB91: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:Checkup]]&lt;br /&gt;
[[Category:Abstract Data Structure]]&lt;br /&gt;
[[Category:Sequence]]&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
'''Representation invariant:'''&lt;br /&gt;
# This abstract data structure is [[Genericity|generic]] and parameterized by a fixed '''key type''' &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt; and a fixed [[comparison]] &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; defined on &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An object with key type &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt; represents a finite, dynamically changing [[multiset]], of elements of type &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt; (the multiset may be empty).&lt;br /&gt;
# An object has two additional attributes, which are natural numbers:&lt;br /&gt;
## Attribute &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; stores the current number of elements (in particular, &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is dynamically changing).&lt;br /&gt;
## Attribute &amp;lt;math&amp;gt;N_\text{max}\in\mathrm{N}&amp;lt;/math&amp;gt; is the maximum number of elements that can be stored in the queue (&amp;lt;math&amp;gt;N_\text{max}&amp;lt;/math&amp;gt; is constant throughout the object's life time).&lt;br /&gt;
# Therefore, at any moment, it is &amp;lt;math&amp;gt;n\le N_\text{max}&amp;lt;/math&amp;gt;.&lt;br /&gt;
'''Constructor:''' Gets a [[comparison]] &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; and a natural number &amp;lt;math&amp;gt;N_\text{max}&amp;lt;/math&amp;gt;, and initializes the queue so as to be empty with a maximum capacity of &amp;lt;math&amp;gt;N_\text{max}&amp;lt;/math&amp;gt; items.&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' insert&lt;br /&gt;
&lt;br /&gt;
'''Input:''' A key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Output:''' A unique ID (natural number), which is permanently associated with the inserted key, until the key is extracted from the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' It is &amp;lt;math&amp;gt;n&amp;lt;N_\text{max}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' The input key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; is inserted into the queue (a.k.a. ''enqueued'').&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' extract minimum&lt;br /&gt;
&lt;br /&gt;
'''Input:''' -&lt;br /&gt;
&lt;br /&gt;
'''Output:''' Returns the minimum key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; that is currently stored in the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' It is &amp;lt;math&amp;gt;n&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' For the minimum key currently stored in the queue, one occurrence is removed (a.k.a. ''dequeued'').&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' find minimum&lt;br /&gt;
&lt;br /&gt;
'''Input:''' -&lt;br /&gt;
&lt;br /&gt;
'''Output:''' Returns the minimum key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; currently stored in the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' It is &amp;lt;math&amp;gt;n&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' -&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' decrease key&lt;br /&gt;
&lt;br /&gt;
'''Input:''' A natural number &amp;lt;math&amp;gt;ID&amp;lt;/math&amp;gt; and a key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Output:''' -&lt;br /&gt;
&lt;br /&gt;
'''Precondition:'''&lt;br /&gt;
# The input is the ID of some queue element (returned on insertion).&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; is not larger according to &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; than the current value of the key to which ID refers.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' The key to which ID refers is now &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; (the old value of that key is lost).&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' number&lt;br /&gt;
&lt;br /&gt;
'''Input:''' -&lt;br /&gt;
&lt;br /&gt;
'''Output:''' The value of attribute &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, that is, the number of keys currently stored in the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' -&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' -&lt;br /&gt;
&lt;br /&gt;
== Known implementations ==&lt;br /&gt;
[[Heap as array]]&lt;br /&gt;
&lt;br /&gt;
== Remark ==&lt;br /&gt;
Usually in applications, the key is actually a pair comprising the key proper and an associated piece of information. In ghis case, the [[Comparison|comparison]] would extract the key proper from each pair and compare the keys proper only.&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Bounded_priority_queue&amp;diff=2705</id>
		<title>Bounded priority queue</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Bounded_priority_queue&amp;diff=2705"/>
		<updated>2014-12-28T14:08:52Z</updated>

		<summary type="html">&lt;p&gt;BB91: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:Checkup]]&lt;br /&gt;
[[Category:Abstract Data Structure]]&lt;br /&gt;
[[Category:Sequence]]&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
'''Representation invariant:'''&lt;br /&gt;
# This abstract data structure is [[Genericity|generic]] and parameterized by a fixed '''key type''' &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt; and a fixed [[comparison]] &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; defined on &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An object with key type &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt; represents a finite, dynamically changing [[multiset]], of elements of type &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt; (the multiset may be empty).&lt;br /&gt;
# An object has two additional attributes, which are natural numbers:&lt;br /&gt;
## Attribute &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; stores the current number of elements (in particular, &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is dynamically changing).&lt;br /&gt;
## Attribute &amp;lt;math&amp;gt;N_\text{max}\in\mathrm{N}&amp;lt;/math&amp;gt; is the maximum number of elements that can be stored in the queue (&amp;lt;math&amp;gt;N_\text{max}&amp;lt;/math&amp;gt; is constant throughout the object's life time).&lt;br /&gt;
# Therefore, at any moment, it is &amp;lt;math&amp;gt;n\le N_\text{max}&amp;lt;/math&amp;gt;.&lt;br /&gt;
'''Constructor:''' Gets a [[comparison]] &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; and a natural number &amp;lt;math&amp;gt;N_\text{max}&amp;lt;/math&amp;gt;, and initializes the queue so as to be empty with a maximum capacity of &amp;lt;math&amp;gt;N_\text{max}&amp;lt;/math&amp;gt; items.&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' insert&lt;br /&gt;
&lt;br /&gt;
'''Input:''' A key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; of type &amp;lt;math&amp;gt;\mathcal{K}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Output:''' A unique ID (natural number), which is permanently associated with the inserted key, until the key is extracted from the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' It is &amp;lt;math&amp;gt;n&amp;lt;N_\text{max}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' The input key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; is inserted into the queue (a.k.a. ''enqueued'').&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' extract minimum&lt;br /&gt;
&lt;br /&gt;
'''Input:''' -&lt;br /&gt;
&lt;br /&gt;
'''Output:''' Returns the minimum key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; that is currently stored in the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' It is &amp;lt;math&amp;gt;n&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' For the minimum key currently stored in the queue, one occurrence is removed (a.k.a. ''dequeued'').&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' find minimum&lt;br /&gt;
&lt;br /&gt;
'''Input:''' -&lt;br /&gt;
&lt;br /&gt;
'''Output:''' Returns the minimum key &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt; currently stored in the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' It is &amp;lt;math&amp;gt;n&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' -&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' decrease key&lt;br /&gt;
&lt;br /&gt;
'''Input:''' A natural number &amp;lt;math&amp;gt;ID&amp;lt;/math&amp;gt; and a real number &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Output:''' -&lt;br /&gt;
&lt;br /&gt;
'''Precondition:'''&lt;br /&gt;
# The input is the ID of some queue element (returned on insertion).&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is not larger than the current value of the key to which ID refers.&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' The key to which ID refers is now &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; (the old value of that key is lost).&lt;br /&gt;
&lt;br /&gt;
== Method ==&lt;br /&gt;
'''Name:''' number&lt;br /&gt;
&lt;br /&gt;
'''Input:''' -&lt;br /&gt;
&lt;br /&gt;
'''Output:''' The value of attribute &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, that is, the number of keys currently stored in the queue.&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' -&lt;br /&gt;
&lt;br /&gt;
'''Postcondition:''' -&lt;br /&gt;
&lt;br /&gt;
== Known implementations ==&lt;br /&gt;
[[Heap as array]]&lt;br /&gt;
&lt;br /&gt;
== Remark ==&lt;br /&gt;
Usually in applications, the key is actually a pair comprising the key proper and an associated piece of information. In ghis case, the [[Comparison|comparison]] would extract the key proper from each pair and compare the keys proper only.&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2703</id>
		<title>Preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2703"/>
		<updated>2014-12-23T14:20:09Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction basis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Max-Flow Problems#Standard version|max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
loop.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A nonnegative integral value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node &amp;lt;math&amp;gt;v\in V\setminus\{t\}&amp;lt;/math&amp;gt; has a '''current arc''', which may be implemented as an iterator on the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The [[Basic flow definitions#Preflow|excess]] &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; of a node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; with respect to the current [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# A (dynamically changing) [[Sets and sequences|set]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of nodes.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; . If all upper bounds are integral, all &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral, too.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\} &amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;e_f(v)\geq 0&amp;lt;/math&amp;gt;. In other words, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# The node labels &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; form a [[Basic flow definitions#Valid distance labeling|valid distance labeling]], and it is &amp;lt;math&amp;gt;d(s)=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The currently [[Basic flow definitions#Preflow|active nodes]] are stored in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
In each iteration, one of the following three actions will take place:&lt;br /&gt;
# The label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of at least one node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; is increased.&lt;br /&gt;
# A saturating push is performed.&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;D:=\sum_{v\in V\setminus\{s,t\}\atop e_f(v)&amp;gt;0}d(v)&amp;lt;/math&amp;gt; decreases.&lt;br /&gt;
No label &amp;lt;math&amp;gt;d(\cdot)&amp;lt;/math&amp;gt; is ever decreased.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
&amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;f(a):=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;(s,v)\in A&amp;lt;/math&amp;gt;, overwrite this value by &amp;lt;math&amp;gt;f(a):=u(a)&amp;lt;/math&amp;gt; and put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Compute a [[Basic flow definitions#Valid distance labeling|valid distance labeling]] &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;, for example, the true distances from all nodes to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;d(s):=n&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the first arc in the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For the [[Basic graph definitions#Subgraphs|subgraph induced]] by &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt;, the arguments in the [[Ahuja-Orlin#Correctness|correctness proof]] for the [[Ahuja-Orlin]] algorithm prove that the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-labels form a valid distance labeling here as well. For &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, nothing is to show because all outgoing arcs are saturated.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Choose an [[Basic flow definitions#Preflow|active node]] &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and not [[Basic flow definitions#Valid distance labeling|admissible]] either, move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is ''not'' void now but an (admissible) outgoing arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;, say:&lt;br /&gt;
## If &amp;lt;math&amp;gt;w\neq s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_f(w)=0&amp;lt;/math&amp;gt;, insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase the flow over &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; by the minimum of &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; and the residual capacity of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;e_f(w)&amp;lt;/math&amp;gt; by that value and decrease &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; by the same value.&lt;br /&gt;
## If &amp;lt;math&amp;gt;e_f(v)=0&amp;lt;/math&amp;gt; now, extract &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;d_\max&amp;lt;/math&amp;gt; denote the minimal label &amp;lt;math&amp;gt;d(w)&amp;lt;/math&amp;gt; of any arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the residual network.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;d(v):=d_\max+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the beginning of the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
The preflow-push algorithm is also known as the '''push-relabel''' algorithm. The ''push'' operation is step 3; the ''relabel'' operation is step 4.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Points 1, 2, and 4 of the invariant and &amp;lt;math&amp;gt;d(s)=n&amp;lt;/math&amp;gt; are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; ensures point 3 of the invariant.&lt;br /&gt;
&lt;br /&gt;
To prove the variant, consider a step in which neither any &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not saturated by that. Potentially, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; becomes active. However, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that &amp;lt;math&amp;gt;d(w)=d(v)-1&amp;lt;/math&amp;gt; for an admissible arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It remains to show termination; this is proved by the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show that the total number of relabel operations (step 4 of the main loop) is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with positive flow on all arcs. The [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is [[Basic flow definitions#Flow-augmenting paths and saturated arcs|augmenting]]. Due to the validity of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; (induction hypothesis), &amp;lt;math&amp;gt;d(v)-d(s)=d(v)-n&amp;lt;/math&amp;gt; cannot be larger than the number of arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, which is not larger than &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, no node label can be larger than &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;. Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.&lt;br /&gt;
&lt;br /&gt;
From this bound, we may immediately conclude that the current arc of a node is reset &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt; times, so the total number of forward steps of the current arcs of all nodes is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The argument in the [[Ahuja-Orlin#Complexity|complexity analysis]] of the [[Ahuja-Orlin]] algorithm to prove that the total number of ''saturating'' push operations is in &amp;lt;math&amp;gt;\mathcal{O}(nm)&amp;lt;/math&amp;gt;, applies here as well.&lt;br /&gt;
&lt;br /&gt;
Finally, we consider the ''non-saturating'' push operations. First note that &amp;lt;math&amp;gt;D\geq 0&amp;lt;/math&amp;gt; before and after each iteration. The value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; increases by less than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total over all relabel operations. On the other hand, a saturating push operation may increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by at most &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt; (namely, in the case that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; was not active immediately before the push). In summary, the total sum of all values by which &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased throughout the algorithm is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;. Due to the variant, the value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased by at least one in each non-saturating push operation. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Heuristic speedup techniques ==&lt;br /&gt;
&lt;br /&gt;
# After &amp;lt;math&amp;gt;\Omega(n)&amp;lt;/math&amp;gt; iterations of the main loop, the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-values are recomputed analogously to the induction basis: as the current distance of each node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.&lt;br /&gt;
# The main loop may be decomposed into two phases: First, as much flow as possible is sent into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;; second, all surplus flow that cannot reach &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is sent back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. The first phase may be finished once there is no more path in the residual network from any active node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. A sufficient and easy-to-check condition for that is &amp;lt;math&amp;gt;d(v)\geq n&amp;lt;/math&amp;gt; for all active nodes &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. All nodes from which &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2702</id>
		<title>Preflow-push</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Preflow-push&amp;diff=2702"/>
		<updated>2014-12-20T10:36:34Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Induction basis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Max-Flow Problems#Standard version|max-flow problem (standard version)]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
loop.&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A nonnegative integral value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Each node &amp;lt;math&amp;gt;v\in V\setminus\{t\}&amp;lt;/math&amp;gt; has a '''current arc''', which may be implemented as an iterator on the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The [[Basic flow definitions#Preflow|excess]] &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; of a node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; with respect to the current [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# A (dynamically changing) [[Sets and sequences|set]] &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of nodes.&lt;br /&gt;
&lt;br /&gt;
'''Invariant:'''&lt;br /&gt;
Before and after each iteration:&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; . If all upper bounds are integral, all &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;-values are integral, too.&lt;br /&gt;
# For each node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\} &amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;e_f(v)\geq 0&amp;lt;/math&amp;gt;. In other words, &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is a [[Basic flow definitions#Preflow|preflow]].&lt;br /&gt;
# The node labels &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; form a [[Basic flow definitions#Valid distance labeling|valid distance labeling]], and it is &amp;lt;math&amp;gt;d(s)=|V|&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The currently [[Basic flow definitions#Preflow|active nodes]] are stored in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Variant:'''&lt;br /&gt;
In each iteration, one of the following three actions will take place:&lt;br /&gt;
# The label &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; of at least one node &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; is increased.&lt;br /&gt;
# A saturating push is performed.&lt;br /&gt;
# The value of &amp;lt;math&amp;gt;D:=\sum_{v\in V\setminus\{s,t\}\atop e_f(v)&amp;gt;0}d(v)&amp;lt;/math&amp;gt; decreases.&lt;br /&gt;
No label &amp;lt;math&amp;gt;d(\cdot)&amp;lt;/math&amp;gt; is ever decreased.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
&amp;lt;math&amp;gt;S=\emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# For all arcs &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;f(a):=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each arc &amp;lt;math&amp;gt;(s,v)\in A&amp;lt;/math&amp;gt;, overwrite this value by &amp;lt;math&amp;gt;f(a):=u(a)&amp;lt;/math&amp;gt; and put &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Compute a valid distance labeling &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;, for example, the true distances from all nodes to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Set &amp;lt;math&amp;gt;d(s):=n&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt;, reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the first arc in the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
For the [[Basic graph definitions#Subgraphs|subgraph induced]] by &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt;, the arguments in the [[Ahuja-Orlin#Correctness|correctness proof]] for the [[Ahuja-Orlin]] algorithm prove that the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-labels form a valid distance labeling here as well. For &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, nothing is to show because all outgoing arcs are saturated.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# Choose an [[Basic flow definitions#Preflow|active node]] &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# While the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is not void and not [[Basic flow definitions#Valid distance labeling|admissible]] either, move the current arc one step forward.&lt;br /&gt;
# If the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is ''not'' void now but an (admissible) outgoing arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;, say:&lt;br /&gt;
## If &amp;lt;math&amp;gt;w\neq s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_f(w)=0&amp;lt;/math&amp;gt;, insert &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase the flow over &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; by the minimum of &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; and the residual capacity of &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Increase &amp;lt;math&amp;gt;e_f(w)&amp;lt;/math&amp;gt; by that value and decrease &amp;lt;math&amp;gt;e_f(v)&amp;lt;/math&amp;gt; by the same value.&lt;br /&gt;
## If &amp;lt;math&amp;gt;e_f(v)=0&amp;lt;/math&amp;gt; now, extract &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Otherwise:&lt;br /&gt;
## Let &amp;lt;math&amp;gt;d_\max&amp;lt;/math&amp;gt; denote the minimal label &amp;lt;math&amp;gt;d(w)&amp;lt;/math&amp;gt; of any arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the residual network.&lt;br /&gt;
## Set &amp;lt;math&amp;gt;d(v):=d_\max+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
## Reset the current arc of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; so as to point to the beginning of the list of outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
The preflow-push algorithm is also known as the '''push-relabel''' algorithm. The ''push'' operation is step 3; the ''relabel'' operation is step 4.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Points 1, 2, and 4 of the invariant and &amp;lt;math&amp;gt;d(s)=n&amp;lt;/math&amp;gt; are obviously fulfilled. The rest of point 3 of the invariant is affected by step 4 only, and the outgoing arcs of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; are the only arcs where the distance labeling may become invalid. However, the extremely conservative increase of &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; ensures point 3 of the invariant.&lt;br /&gt;
&lt;br /&gt;
To prove the variant, consider a step in which neither any &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-value is increased nor a saturating push is performed. This means step 3.2 is applied, but the arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not saturated by that. Potentially, &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; becomes active. However, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; definitely becomes inactive since the push step is non-saturating. Now the variant follows from the fact that &amp;lt;math&amp;gt;d(w)=d(v)-1&amp;lt;/math&amp;gt; for an admissible arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It remains to show termination; this is proved by the following complexity considerations.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n=|V|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;m=|A|&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
First we show that the total number of relabel operations (step 4 of the main loop) is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v\in V\setminus\{s,t\}&amp;lt;/math&amp;gt; be an active node between two iterations of the main loop. A straightforward induction over the number of push operations shows that there is at least one simple &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; with positive flow on all arcs. The [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is [[Basic flow definitions#Flow-augmenting paths and saturated arcs|augmenting]]. Due to the validity of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; (induction hypothesis), &amp;lt;math&amp;gt;d(v)-d(s)=d(v)-n&amp;lt;/math&amp;gt; cannot be larger than the number of arcs on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, which is not larger than &amp;lt;math&amp;gt;n-1&amp;lt;/math&amp;gt;. Therefore, no node label can be larger than &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;. Since node labels are nonnegative and increase at least by one in each relabel operation, the claimed upper bound on the relabel operations follows.&lt;br /&gt;
&lt;br /&gt;
From this bound, we may immediately conclude that the current arc of a node is reset &amp;lt;math&amp;gt;\mathcal{O}(n)&amp;lt;/math&amp;gt; times, so the total number of forward steps of the current arcs of all nodes is in &amp;lt;math&amp;gt;\mathcal{O}(n^2)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The argument in the [[Ahuja-Orlin#Complexity|complexity analysis]] of the [[Ahuja-Orlin]] algorithm to prove that the total number of ''saturating'' push operations is in &amp;lt;math&amp;gt;\mathcal{O}(nm)&amp;lt;/math&amp;gt;, applies here as well.&lt;br /&gt;
&lt;br /&gt;
Finally, we consider the ''non-saturating'' push operations. First note that &amp;lt;math&amp;gt;D\geq 0&amp;lt;/math&amp;gt; before and after each iteration. The value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased in each relabel operation exactly by the amount by which the label of the current node is increased. Since node labels are never decreased and bounded from above by &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; increases by less than &amp;lt;math&amp;gt;2n^2&amp;lt;/math&amp;gt; in total over all relabel operations. On the other hand, a saturating push operation may increase &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; by at most &amp;lt;math&amp;gt;2n-1&amp;lt;/math&amp;gt; (namely, in the case that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; was not active immediately before the push). In summary, the total sum of all values by which &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is increased throughout the algorithm is in &amp;lt;math&amp;gt;\mathcal{O}(n^2m)&amp;lt;/math&amp;gt;. Due to the variant, the value of &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; is decreased by at least one in each non-saturating push operation. This proves the claim.&lt;br /&gt;
&lt;br /&gt;
== Heuristic speedup techniques ==&lt;br /&gt;
&lt;br /&gt;
# After &amp;lt;math&amp;gt;\Omega(n)&amp;lt;/math&amp;gt; iterations of the main loop, the &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;-values are recomputed analogously to the induction basis: as the current distance of each node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; in the residual network. This modification is seldom enough, so the asymptotic complexity is not increased. In practice, this technique may save many unnecessary relabel steps.&lt;br /&gt;
# The main loop may be decomposed into two phases: First, as much flow as possible is sent into &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;; second, all surplus flow that cannot reach &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is sent back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. The first phase may be finished once there is no more path in the residual network from any active node to &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;. A sufficient and easy-to-check condition for that is &amp;lt;math&amp;gt;d(v)\geq n&amp;lt;/math&amp;gt; for all active nodes &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. All nodes from which &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is reachable may be safely disregarded in the second phase. For any other node, to save unnecessary relabel operations, the distance label may be safely increased to the minimum number of arcs in the residual network from this node back to &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Basic_flow_definitions&amp;diff=2701</id>
		<title>Basic flow definitions</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Basic_flow_definitions&amp;diff=2701"/>
		<updated>2014-12-20T10:32:22Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Preflow */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic definitions ==&lt;br /&gt;
&lt;br /&gt;
# [[Basic graph definitions]]&lt;br /&gt;
&lt;br /&gt;
== Basic setting ==&lt;br /&gt;
On this page and all dependent pages, &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; is an [[Basic graph definitions#Directed and undirected graphs|anti-symmetric, simple directed graph]], unless stated otherwise. &lt;br /&gt;
# For &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, there is a nonnegative '''upper bound''' &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# In some flow problems, there is a '''lower bound''' &amp;lt;math&amp;gt;\ell(a)&amp;lt;/math&amp;gt; as well, which need not be nonnegative.&lt;br /&gt;
# In some flow problems, each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; has a '''required balance''' (or '''balance''' for short) &amp;lt;math&amp;gt;b(v)&amp;lt;/math&amp;gt;. We also speak of the '''node balance'''.&lt;br /&gt;
# In some flow problems, there is a real-valued (not necessarily nonnegative) '''cost factor''' &amp;lt;math&amp;gt;c(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
Other node and arc attributes may occur in specific flow problems. Unless stated otherwise, there are no  node or arc attributes except for the upper bounds on arcs.&lt;br /&gt;
&lt;br /&gt;
'''Neutral values of attributes:'''&lt;br /&gt;
When a node or arc is added to a graph, it is sometimes appropriate to set its attributes to neutral values. The neutral values for upper and lower bounds are &amp;lt;math&amp;gt;+\infty&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;-\infty&amp;lt;/math&amp;gt;, respectively. For cost factors and node balances, the neutral value is zero.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
Simplicity and anti-symmetry do not reduce generality in the context of flow problems:&lt;br /&gt;
# If there are two arcs &amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;, say, from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;, add a new node &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, replace &amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt; by new arcs &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(u,w)&amp;lt;/math&amp;gt;, transfer the attribute values of &amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; and set all attributes of &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; and of &amp;lt;math&amp;gt;(u,w)&amp;lt;/math&amp;gt; to their neutral values.&lt;br /&gt;
# If there is a loop &amp;lt;math&amp;gt;(v,v)&amp;lt;/math&amp;gt;, add a new node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, replace &amp;lt;math&amp;gt;(v,v)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt;, and set the attribute values analogously to the case of parallel arcs.&lt;br /&gt;
# If &amp;lt;math&amp;gt;(v,w),(w,v)\in A&amp;lt;/math&amp;gt; add a new node &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, replace  &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by new arcs &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(u,w)&amp;lt;/math&amp;gt;, and set the attribute values analogously to the case of parallel arcs.&lt;br /&gt;
&lt;br /&gt;
'''Integrality assumption:'''&lt;br /&gt;
All numerical node and arc attributes are integral.&lt;br /&gt;
&lt;br /&gt;
In the context of flow problems, this assumption does not reduce generality, either: Choosing a sufficiently small &amp;lt;math&amp;gt;\delta&amp;gt;0&amp;lt;/math&amp;gt; and replacing each attribute value by the nearest integral multiple of &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; has a negligible impact on the output.&lt;br /&gt;
&lt;br /&gt;
== Feasible flow ==&lt;br /&gt;
&lt;br /&gt;
'''Capacity constraints:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; be an arc weighting, that is, a value &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; is given for each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
# We say that &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; fulfills the '''capacity constraints''' if &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If lower bounds &amp;lt;math&amp;gt;\ell&amp;lt;/math&amp;gt; are given, the condition &amp;lt;math&amp;gt;f(a)\geq 0&amp;lt;/math&amp;gt; is to be replaced by &amp;lt;math&amp;gt;f(a)\geq\ell(a)&amp;lt;/math&amp;gt;. In particular, &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; may be negative if &amp;lt;math&amp;gt;\ell(a)&amp;lt;/math&amp;gt; is so.&lt;br /&gt;
&lt;br /&gt;
'''Flow conservation condition:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;W\subseteq V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An arc weighting fulfills the flow conservation condition with respect to &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; if for all nodes &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;: &amp;lt;math&amp;gt;\sum_{w\in V\atop(v,w)\in A}f(v,w)-\sum_{w\in V\atop(w,v)\in A}f(w,v)=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If there are balance values &amp;lt;math&amp;gt;b(v)&amp;lt;/math&amp;gt; for all nodes &amp;lt;math&amp;gt;v\in V\setminus W&amp;lt;/math&amp;gt;, the right-hand side of this condition is not zero but &amp;lt;math&amp;gt;b(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A '''feasible flow''' (or '''flow''' for short) with respect to &amp;lt;math&amp;gt;W\subseteq V&amp;lt;/math&amp;gt; is an arc weighting that satisfies the capacity constraints and the flow conservation condition.&lt;br /&gt;
&lt;br /&gt;
== Preflow ==&lt;br /&gt;
&lt;br /&gt;
# Preflows generalize feasible flows as follows: Instead of an equation, the following inequality is to be fulfilled for each &amp;lt;math&amp;gt;v\in V\setminus W&amp;lt;/math&amp;gt;: &amp;lt;math&amp;gt;\sum_{w:(w,v)\in A}f(w,v)-\sum_{w:(v,w)\in A}f(v,w)\geq 0&amp;lt;/math&amp;gt; (resp., &amp;lt;math&amp;gt;\geq b(v)&amp;lt;/math&amp;gt;, if node balances are given).&lt;br /&gt;
# The '''excess''' of &amp;lt;math&amp;gt;v\in V\setminus W&amp;lt;/math&amp;gt; is the value of the left-hand side of that inequality. A node is '''active''' if its excess is strictly positive.&lt;br /&gt;
&lt;br /&gt;
== Flow value ==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;S,T\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;S\cap T=\emptyset&amp;lt;/math&amp;gt;, and let &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; be a flow with respect to &amp;lt;math&amp;gt;S\cup T&amp;lt;/math&amp;gt;. The '''flow value''' &amp;lt;math&amp;gt;v(f)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined by&lt;br /&gt;
:&amp;lt;math&amp;gt;v(f):=\sum_{s\in S,v\in V\setminus S\atop(s,v)\in A}f(s,v)-\sum_{s\in S,v\in V\setminus S\atop(v,s)\in A}f(v,s)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
A straightforward induction on &amp;lt;math&amp;gt;k\geq|S|&amp;lt;/math&amp;gt; shows that for all partitions &amp;lt;math&amp;gt;(V_S,V_T)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;|V_S|=k&amp;lt;/math&amp;gt;, it is&lt;br /&gt;
:&amp;lt;math&amp;gt;v(f)=\sum_{v\in V_S,w\in V_T\atop(v,w)\in A}f(v,w)-\sum_{v\in V_S,w\in V_T\atop(w,v)\in A}f(w,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
In particular, mirror-symmetrically to the definition of &amp;lt;math&amp;gt;v(f)&amp;lt;/math&amp;gt;, it is&lt;br /&gt;
:&amp;lt;math&amp;gt;v(f)=\sum_{v\in V\setminus T,t\in T\atop(v,t)\in A}f(v,t)-\sum_{v\in V\setminus T,t\in T\atop(t,v)\in A}f(t,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Residual network ==&lt;br /&gt;
&lt;br /&gt;
The '''residual network''' &amp;lt;math&amp;gt;(G_f,u_f)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;(G,u)&amp;lt;/math&amp;gt; with respect to an arc weighting &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as follows: It is &amp;lt;math&amp;gt;G_f=(V,A_f)&amp;lt;/math&amp;gt;, and for each arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt;, we have:&lt;br /&gt;
# &amp;lt;math&amp;gt;(v,w)\in A_f&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;u_f(v,w)=u(v,w)-f(v,w)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;u(v,w)-f(v,w)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# &amp;lt;math&amp;gt;(w,v)\in A_f&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;u_f(w,v)=f(v,w)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f(v,w)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
The value &amp;lt;math&amp;gt;u_f(a)&amp;lt;/math&amp;gt; of an arc &amp;lt;math&amp;gt;a\in A_f&amp;lt;/math&amp;gt;is called the '''residual capacity''' of &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
Changes of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and changes of &amp;lt;math&amp;gt;u_f&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G_f&amp;lt;/math&amp;gt; are equivalent in an obvious way. Since &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is anti-symmetric, this equivalence is one-to-one. So, the view on &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is exchangeable with the view on &amp;lt;math&amp;gt;G_f&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u_f&amp;lt;/math&amp;gt;. We will adopt both views simultaneously in the presentation and discussion of the individual algorithms. An implementation of an algorithm may be based on &amp;lt;math&amp;gt;(G,f)&amp;lt;/math&amp;gt; or on &amp;lt;math&amp;gt;(G_f,u_f)&amp;lt;/math&amp;gt; or even on both representations simultaneously.&lt;br /&gt;
&lt;br /&gt;
== Flow-augmenting paths and saturated arcs ==&lt;br /&gt;
&lt;br /&gt;
A '''flow-augmenting path''' (or '''augmenting path''' for short) from some node &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;t\in V&amp;lt;/math&amp;gt; is an [[Basic graph definitions#Paths|ordinary path]] in the residual network &amp;lt;math&amp;gt;G_f&amp;lt;/math&amp;gt;. Equivalently, a flow-augmenting path is a [[Basic graph definitions#Paths|generalized path]] in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that:&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)&amp;lt;u(a)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a forward arc;&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)&amp;gt;0&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a backward arc.&lt;br /&gt;
An arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is '''saturated'''&lt;br /&gt;
# in forward direction if &amp;lt;math&amp;gt;f(a)=u(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# in backward direction if &amp;lt;math&amp;gt;f(a)=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
We say that an arc of a path is '''saturated''' if it is saturated in the direction of this path. Clearly, a path is augmenting if, and only if, it contains no saturated arc in its direction.&lt;br /&gt;
&lt;br /&gt;
== Augmenting along a path ==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; denote some flow-augmenting path in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, and let &amp;lt;math&amp;gt;\varepsilon&amp;gt;0&amp;lt;/math&amp;gt; such that&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)+\varepsilon\leq u(a)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a forward arc;&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)-\varepsilon\geq 0&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a backward arc.&lt;br /&gt;
In the residual network &amp;lt;math&amp;gt;(G_f,u_f)&amp;lt;/math&amp;gt;, '''augmenting''' &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; along the [[Basic graph definitions#Paths|ordinary path]] induced by &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; means reducing all residual capacities by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt;. Equivalently, for each arc &amp;lt;math&amp;gt;a \in A&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, this means:  &lt;br /&gt;
# Increase the flow value by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is a forward arc on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Decrease the flow value by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is a backward arc on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
Obviously, the capacity constraints are preserved. The flow conservation conditions are preserved at every [[Basic graph definitions#Paths|internal node]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be such an internal node, and let &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; denote the immediate predecessor and successor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, respectively. Basically, there are four cases:&lt;br /&gt;
*Either &amp;lt;math&amp;gt;(u,v)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as a forward arc or &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;  as a backward arc.&lt;br /&gt;
*Either &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as a forward arc or &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as a backward arc.&lt;br /&gt;
It is easy to check preservation of the flow conservation conditions at &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; for each of these four cases.&lt;br /&gt;
&lt;br /&gt;
'''Augmenting up to saturation:'''&lt;br /&gt;
Again, let &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; denote some flow-augmenting path.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;\varepsilon_1&amp;gt;0&amp;lt;/math&amp;gt; denote the minimum of the values &amp;lt;math&amp;gt;u(a)-f(a)&amp;lt;/math&amp;gt; on all forward arcs of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;\varepsilon_2&amp;gt;0&amp;lt;/math&amp;gt; denote the minimum of the values &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; on all backward arcs of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; denote the minimum of &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\varepsilon_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
Augmenting the flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; along &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; yields at least one saturated arc.&lt;br /&gt;
&lt;br /&gt;
== Cuts and saturated cuts ==&lt;br /&gt;
&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; be a directed graph and &amp;lt;math&amp;gt;s,t\in V&amp;lt;/math&amp;gt;. An &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-'''cut''' (or '''cut''' for short) is a bipartition &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;s\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t\in T&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; be real values such that &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; (&amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; need not be a flow here). A cut &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; is '''saturated''' if:&lt;br /&gt;
## &amp;lt;math&amp;gt;f(v,w)=u(v,w)&amp;lt;/math&amp;gt; for every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in T&amp;lt;/math&amp;gt;.&lt;br /&gt;
## &amp;lt;math&amp;gt;f(v,w)=0&amp;lt;/math&amp;gt; for every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v\in T&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Valid distance labeling ==&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; be a directed graph, and for each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; be defined such that &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt;. An assignment of a value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; to each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is a '''valid distance labeling''' if the following two conditions ar fulfilled:&lt;br /&gt;
## It is &amp;lt;math&amp;gt;d(t)=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
## For each arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; in the residual network, it is &amp;lt;math&amp;gt;d(v)\leq d(w)+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If even &amp;lt;math&amp;gt;d(v)=d(w)+1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is called an '''admissible arc'''.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2381</id>
		<title>Hopcroft-Tarjan</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Hopcroft-Tarjan&amp;diff=2381"/>
		<updated>2014-11-27T16:24:01Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Step 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:'''&lt;br /&gt;
[[Biconnected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:'''&lt;br /&gt;
two steps.&lt;br /&gt;
&lt;br /&gt;
== Step 1 ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
# A start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and an edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; to an arbitrarily chosen node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; are added to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The core algorithm is a variation of [[Depth-first search|DFS]], where for each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; two additional nonnegative integral numbers are computed:&lt;br /&gt;
## The '''depth''' of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence created by the DFS procedure.&lt;br /&gt;
## The '''lowpoint''', that is, the minimal depth of any node &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;(u,w)\in A&amp;lt;/math&amp;gt; for some immediate or non-immediate successor &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the DFS tree.&lt;br /&gt;
# The start node &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and the edge &amp;lt;math&amp;gt;\{s,v\}&amp;lt;/math&amp;gt; are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and from the DFS arborescence (which is rooted at &amp;lt;matH&amp;gt;v&amp;lt;/math&amp;gt; afterwards).&lt;br /&gt;
&lt;br /&gt;
'''Implementation of step 1:'''&lt;br /&gt;
# ''Depth'': The DFS maintains a global integral number, the '''current depth'''. Whenever a node is seen for the first time, its depth attribute is set identical to the current depth. In each forward step, the current depth is ''in''creased by one, in each backward step, it is ''de''creased by one.&lt;br /&gt;
# ''Lowpoint'':&lt;br /&gt;
## Whenever a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is seen for the first time, its lowpoint is set identical to its depth.&lt;br /&gt;
## Whenever an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is examined such that &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; has already been seen and the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the depth of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
## In each backward step of DFS from a node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; back to its immediate predecessor &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;: If the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is smaller than the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the lowpoint value of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is set identical to the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remarks:'''&lt;br /&gt;
# We do not choose a start node from the given nodes but insert a new start node to avoid a special treatment of the start node.&lt;br /&gt;
# This is another example where it makes perfect sense to implement graph traversal algorithms as iterators (cf. [[Graph traversal#Remarks|here]]). In fact, then the operations on the depth and lowpoint attributes can be inserted in the DFS loop in an easy, obvious way.&lt;br /&gt;
&lt;br /&gt;
== Step 2 ==&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
A node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is '''essential''' if, for at least one arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; in the arborescence from step 1, the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:'''&lt;br /&gt;
A repeated application of [[Depth-first search|DFS]], where the start nodes of the individual DFS runs are the essential nodes. In that, the essential nodes are considered in ascending order of their finishing times as computed in step 1. The nodes hit in one DFS run are removed from &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; before the next DFS run commences. The node sets visited in the individual DFS runs are returned as the biconnected components.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
Obviously, the depth and the lowpoint are set correctly according to their intended semantics.&lt;br /&gt;
&lt;br /&gt;
First consider an essential node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; be an arc in the arborescence such that the lowpoint value of &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. We have to show that the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; only. So suppose for a contradiction that there is an edge &amp;lt;math&amp;gt;\{x,y\}&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; belongs to that subarborescence and &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; does not. Then &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; must have been seen before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, because otherwise, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; would be in the subarborescence rooted at &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. Since the lowpoint of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is equal to or larger than the depth of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; cannot be a predecessor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in the arborescence. Hence, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was even finished before &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; was seen. In particular, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; was finished before &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; was seen, which is impossible.&lt;br /&gt;
&lt;br /&gt;
Now consider a node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; that is ''not'' essential. Opposite to the first case, we have to show that the subarborescence rooted at an arc &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is not only connected to the rest of the graph via &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. However, this follows immediately from the definition of the lowpoint value: There is some &amp;lt;math&amp;gt;x\in V&amp;lt;/math&amp;gt; in the subarborescence rooted at &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; connected to some node &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; that cannot be in the subarborescence due to its smaller depth.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:'''&lt;br /&gt;
The asymptotic complexity is linear.&lt;br /&gt;
&lt;br /&gt;
'''Proof:'''&lt;br /&gt;
Follows immediately from the linear asymptotic complexity of DFS.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Main_Page&amp;diff=2192</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Main_Page&amp;diff=2192"/>
		<updated>2014-11-18T11:28:08Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Flow Algorithms */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== News ==&lt;br /&gt;
* The http://wiki.algo.informatik.tu-darmstadt.de domain will forward to this page from 13th October.&lt;br /&gt;
* The old wiki will be reachable at http://huffmann.algo.informatik.tu-darmstadt.de/wiki/&lt;br /&gt;
* &amp;lt;math&amp;gt;LaTeX&amp;lt;/math&amp;gt; [http://www.mediawiki.org/wiki/Manual:Math available now!]&lt;br /&gt;
* ToDo List added&lt;br /&gt;
* Every content has to be in English!&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi Syntaxhighlight]&lt;br /&gt;
&lt;br /&gt;
== Rules ==&lt;br /&gt;
* Add finalized reconstructions of the old Wiki to Category:Checkup.&lt;br /&gt;
* Don't any non-Weihe content until the reconstructions isn't finished.&lt;br /&gt;
* Keep your active reconstructing Pages in &amp;quot;Division of labor&amp;quot; section up to date!&lt;br /&gt;
&lt;br /&gt;
'''Look here for short/uncomplete Pages''' [[Special:ShortPages]]&lt;br /&gt;
&lt;br /&gt;
== Page Status ==&lt;br /&gt;
Final: [[:Category:Checkup]]&lt;br /&gt;
&lt;br /&gt;
== To Do ==&lt;br /&gt;
=== Notations ===&lt;br /&gt;
* [[Big O notation]]&lt;br /&gt;
* [[L' Hospital]]&lt;br /&gt;
* [[Master theorem]]&lt;br /&gt;
&lt;br /&gt;
=== Problems ===&lt;br /&gt;
* [[Matchings in graphs#Cardinality-maximal matching|Maximum matching problem]]&lt;br /&gt;
* [[Max-Flow Problems]]&lt;br /&gt;
* [[Min-Cost Flow Problems]]&lt;br /&gt;
* [[Shortest Paths Problems]]&lt;br /&gt;
** [[All pairs shortest paths]]&lt;br /&gt;
*** [[Floyd-Warshall]]&lt;br /&gt;
*** [[Bellman-Ford]] (DONE)&lt;br /&gt;
*** [[Shortest paths by repeated squaring]] (variant of Bellman-Ford) &lt;br /&gt;
** [[Single source shortest paths]]&lt;br /&gt;
*** [[Dijkstra]]&lt;br /&gt;
** [[Single source single target shortest paths]]&lt;br /&gt;
*** [[A*]]&lt;br /&gt;
* [[Maximum spanning forest]]&lt;br /&gt;
* [[Problems on Sequences]]&lt;br /&gt;
** [[Basic Problems on Sequences]]&lt;br /&gt;
*** [[Find an element in a sequence]] (DONE)&lt;br /&gt;
*** [[Insert an element in a sequence]] (Empty in old wiki?!)&lt;br /&gt;
*** [[Median]] (DONE)&lt;br /&gt;
*** [[Merging two sorted sequences]] (DONE)&lt;br /&gt;
** [[Pattern Matching]]&lt;br /&gt;
*** [[One-dimensional string matching]] (DONE)&lt;br /&gt;
*** [[String matching]] (DONE)&lt;br /&gt;
** [[Sorting]]&lt;br /&gt;
*** [[Sorting based on pairwise comparison]] (DONE)&lt;br /&gt;
*** [[Sorting Sequences of Strings]] (DONE)&lt;br /&gt;
&lt;br /&gt;
=== Coding Basics ===&lt;br /&gt;
* [[Inheritance]]&lt;br /&gt;
* [[Generics]]&lt;br /&gt;
* [[Collections]]&lt;br /&gt;
** [[Iterator]]&lt;br /&gt;
** [[Comparator]]&lt;br /&gt;
&lt;br /&gt;
=== String Matching Algorithms ===&lt;br /&gt;
* [[Simple string matching algorithm]] (DONE)&lt;br /&gt;
* [[String matching based on finite automaton]] (DONE)&lt;br /&gt;
&lt;br /&gt;
=== Sorting Algorithms ===&lt;br /&gt;
* [[Bubble]]&lt;br /&gt;
* [[Insertion sort]]&lt;br /&gt;
* [[Quicksort]]&lt;br /&gt;
* [[Bubblesort]]&lt;br /&gt;
* [[Mergesort]]&lt;br /&gt;
* [[Bucketsort]]&lt;br /&gt;
* [[Selection sort]]&lt;br /&gt;
* [[Bogosort]]&lt;br /&gt;
&lt;br /&gt;
=== Search Algorithms ===&lt;br /&gt;
* [[Binary search]]&lt;br /&gt;
&lt;br /&gt;
=== Auxillary Algorithms ===&lt;br /&gt;
* [[Pivot partitioning by scanning]]&lt;br /&gt;
&lt;br /&gt;
=== Manipulation ===&lt;br /&gt;
* [[Array list: find]]&lt;br /&gt;
* [[Array list: find at position]]&lt;br /&gt;
* [[Array list: insert at head]]&lt;br /&gt;
* [[Array list: insert at position]]&lt;br /&gt;
* [[Array list: number]]&lt;br /&gt;
* [[Array list: remove]]&lt;br /&gt;
* [[Doubly-linked list: insert at position]]&lt;br /&gt;
* [[Doubly-linked list: insert at tail]]&lt;br /&gt;
* [[Doubly-linked list: remove]]&lt;br /&gt;
* [[Find element in sequence iteratively]]&lt;br /&gt;
* [[Find element in sequence recursively]]&lt;br /&gt;
* [[Hashtable: find]]&lt;br /&gt;
* [[Hashtable: insert]]&lt;br /&gt;
&lt;br /&gt;
=== Tree Algorithms ===&lt;br /&gt;
* [[Depth-first search]]&lt;br /&gt;
* [[Breadth-first search]]&lt;br /&gt;
* [[B-tree: find]]&lt;br /&gt;
* [[B-tree: minimum]]&lt;br /&gt;
* [[B-tree: maximum]]&lt;br /&gt;
* [[B-tree: insert]]&lt;br /&gt;
* [[B-tree: insert and rearrange]]&lt;br /&gt;
* [[B-tree: merge two siblings]]&lt;br /&gt;
* [[B-tree: remove]]&lt;br /&gt;
* [[B-tree: shift key to sibling]]&lt;br /&gt;
* [[B-tree: rotate]]&lt;br /&gt;
* [[B-tree: merge]]&lt;br /&gt;
* [[B-tree: split]]&lt;br /&gt;
* [[Binary search tree: find]]&lt;br /&gt;
* [[Binary search tree: minimum]]&lt;br /&gt;
* [[Binary search tree: maximum]]&lt;br /&gt;
* [[Binary search tree: insert]]&lt;br /&gt;
* [[Binary search tree: remove]]&lt;br /&gt;
* [[Binary search tree: remove node]]&lt;br /&gt;
* [[Binary search tree: traverse]]&lt;br /&gt;
&lt;br /&gt;
=== Graph Theory ===&lt;br /&gt;
* [[Directed graph]]&lt;br /&gt;
* [[Bipartite graph|Bipartite graph]] (DONE)&lt;br /&gt;
* [[k-partite graph]]&lt;br /&gt;
* [[Negative paths]]&lt;br /&gt;
&lt;br /&gt;
=== Graph Algorithms ===&lt;br /&gt;
* [[Dijkstra]]&lt;br /&gt;
* [[Kruskal]]&lt;br /&gt;
* [[Prim]]&lt;br /&gt;
* [[Bellman-Ford]] (DONE)&lt;br /&gt;
* [[Floyd-Warshall]]&lt;br /&gt;
* [[Union Find]]&lt;br /&gt;
* [[A*]]&lt;br /&gt;
* [[Alternating paths algorithm]]&lt;br /&gt;
* [[Johnson]]&lt;br /&gt;
* [[Union-find with disjoint trees: find]]&lt;br /&gt;
* [[Union-find with lists: unite]]&lt;br /&gt;
* [[Max-flow min-cut]]&lt;br /&gt;
&lt;br /&gt;
=== Flow Algorithms ===&lt;br /&gt;
* [[Ford-Fulkerson]]&lt;br /&gt;
* [[Edmonds-Karp]]&lt;br /&gt;
&lt;br /&gt;
=== Abstract Data Structures ===&lt;br /&gt;
*[[Network Structures]]&lt;br /&gt;
**[[Graph]]&lt;br /&gt;
**[[Tree]]&lt;br /&gt;
*[[Sequence]]&lt;br /&gt;
**[[Sorted sequence]]&lt;br /&gt;
**[[Bounded priority queue]]&lt;br /&gt;
**[[Linear sequence]]&lt;br /&gt;
**[[Priority queue]]&lt;br /&gt;
**[[Sorted sequence]]&lt;br /&gt;
=== Implementations of Abstract Data Structures  ===&lt;br /&gt;
* [[Linked list]]&lt;br /&gt;
* [[Array list]]&lt;br /&gt;
* [[Binary search tree]]&lt;br /&gt;
* [[Doubly-linked list]]&lt;br /&gt;
* [[Heap as array]] (DONE (Heap as Array))&lt;br /&gt;
* [[Hashtable]]&lt;br /&gt;
* [[Multi-way search tree]]&lt;br /&gt;
* [[Red-black tree]]&lt;br /&gt;
* [[B-tree]]&lt;br /&gt;
&lt;br /&gt;
=== ??? ===&lt;br /&gt;
* [[Min-Max Heaps]]&lt;br /&gt;
* [[First In - First Out]]&lt;br /&gt;
* [[First In - Last Out]]&lt;br /&gt;
* [[Directed Tree]]&lt;br /&gt;
* [[Decision Tree]]&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
* [[Model computer]]&lt;br /&gt;
&lt;br /&gt;
=== Other Algorithms (LOCKED) ===&lt;br /&gt;
* [[B*]]&lt;br /&gt;
* [[Cyclic redundancy check]]&lt;br /&gt;
* [[Euclid]]&lt;br /&gt;
* [[Gauss]]&lt;br /&gt;
* [[Discrete fourier transform]]&lt;br /&gt;
* [[Fast fourier transform]]&lt;br /&gt;
* [[Bresenham]]&lt;br /&gt;
* [[Round robin]]&lt;br /&gt;
* [[Seperate and conquer]]&lt;br /&gt;
* [[Message-Digest algorithm]]&lt;br /&gt;
* [[Secure hash algorithm]]&lt;br /&gt;
* [[Sequent calculus]]&lt;br /&gt;
* [[Resolution calculus]]&lt;br /&gt;
* [[Cocke-Younger-Kasami algorithm]]&lt;br /&gt;
* [[Distance vector routing]]&lt;br /&gt;
* [[Link state routing]]&lt;br /&gt;
* [[Z Buffer algorithm]]&lt;br /&gt;
* [[Marching squares]]&lt;br /&gt;
* [[Marching cubes]]&lt;br /&gt;
* [[Bottom-Up heapsort]]&lt;br /&gt;
* [[Radixsort]]&lt;br /&gt;
* [[Median cut]]&lt;br /&gt;
* [[Pancake sorting]]&lt;br /&gt;
* [[Karnaugh-Veitch diagramm]]&lt;br /&gt;
* [[Delanuay triangulation]]&lt;br /&gt;
* [[Backtracking]]&lt;br /&gt;
* [[Alpha–beta pruning]]&lt;br /&gt;
* [[Beam search]]&lt;br /&gt;
* [[Best-first search]]&lt;br /&gt;
* [[Bidirectional search]]&lt;br /&gt;
* [[Borůvka's algorithm]]&lt;br /&gt;
* [[Branch and bound]]&lt;br /&gt;
* [[D*]]&lt;br /&gt;
* [[Depth-limited search]]&lt;br /&gt;
* [[Edmonds' algorithm]]&lt;br /&gt;
* [[Fringe search]]&lt;br /&gt;
* [[Hill climbing]]&lt;br /&gt;
* [[IDA*]]&lt;br /&gt;
* [[Iterative deepening depth-first search]]&lt;br /&gt;
* [[Jump point search]]&lt;br /&gt;
* [[Lexicographic breadth-first search]]&lt;br /&gt;
* [[SMA*]]&lt;br /&gt;
* [[Uniform-cost search]]&lt;br /&gt;
&lt;br /&gt;
=== Other Data Structures (LOCKED) ===&lt;br /&gt;
* [[Adelson-Velskii and Landis' tree]]&lt;br /&gt;
* [[Patricia-Trie]]&lt;br /&gt;
* [[Suffix Tree]]&lt;br /&gt;
* [[Huffmann Tree]]&lt;br /&gt;
* [[Binary Expression Tree]]&lt;br /&gt;
* [[Hash Set]]&lt;br /&gt;
* [[Incidence Matrix]]&lt;br /&gt;
* [[Voronoi Diagramm]]&lt;br /&gt;
* [[Quad Tree]]&lt;br /&gt;
* [[Oct Tree]]&lt;br /&gt;
* [[kd Tree]]&lt;br /&gt;
* [[Binary space partitioning]]&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Main_Page&amp;diff=2191</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Main_Page&amp;diff=2191"/>
		<updated>2014-11-18T11:24:45Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* To Do */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== News ==&lt;br /&gt;
* The http://wiki.algo.informatik.tu-darmstadt.de domain will forward to this page from 13th October.&lt;br /&gt;
* The old wiki will be reachable at http://huffmann.algo.informatik.tu-darmstadt.de/wiki/&lt;br /&gt;
* &amp;lt;math&amp;gt;LaTeX&amp;lt;/math&amp;gt; [http://www.mediawiki.org/wiki/Manual:Math available now!]&lt;br /&gt;
* ToDo List added&lt;br /&gt;
* Every content has to be in English!&lt;br /&gt;
* [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi Syntaxhighlight]&lt;br /&gt;
&lt;br /&gt;
== Rules ==&lt;br /&gt;
* Add finalized reconstructions of the old Wiki to Category:Checkup.&lt;br /&gt;
* Don't any non-Weihe content until the reconstructions isn't finished.&lt;br /&gt;
* Keep your active reconstructing Pages in &amp;quot;Division of labor&amp;quot; section up to date!&lt;br /&gt;
&lt;br /&gt;
'''Look here for short/uncomplete Pages''' [[Special:ShortPages]]&lt;br /&gt;
&lt;br /&gt;
== Page Status ==&lt;br /&gt;
Final: [[:Category:Checkup]]&lt;br /&gt;
&lt;br /&gt;
== To Do ==&lt;br /&gt;
=== Notations ===&lt;br /&gt;
* [[Big O notation]]&lt;br /&gt;
* [[L' Hospital]]&lt;br /&gt;
* [[Master theorem]]&lt;br /&gt;
&lt;br /&gt;
=== Problems ===&lt;br /&gt;
* [[Matchings in graphs#Cardinality-maximal matching|Maximum matching problem]]&lt;br /&gt;
* [[Max-Flow Problems]]&lt;br /&gt;
* [[Min-Cost Flow Problems]]&lt;br /&gt;
* [[Shortest Paths Problems]]&lt;br /&gt;
** [[All pairs shortest paths]]&lt;br /&gt;
*** [[Floyd-Warshall]]&lt;br /&gt;
*** [[Bellman-Ford]] (DONE)&lt;br /&gt;
*** [[Shortest paths by repeated squaring]] (variant of Bellman-Ford) &lt;br /&gt;
** [[Single source shortest paths]]&lt;br /&gt;
*** [[Dijkstra]]&lt;br /&gt;
** [[Single source single target shortest paths]]&lt;br /&gt;
*** [[A*]]&lt;br /&gt;
* [[Maximum spanning forest]]&lt;br /&gt;
* [[Problems on Sequences]]&lt;br /&gt;
** [[Basic Problems on Sequences]]&lt;br /&gt;
*** [[Find an element in a sequence]] (DONE)&lt;br /&gt;
*** [[Insert an element in a sequence]] (Empty in old wiki?!)&lt;br /&gt;
*** [[Median]] (DONE)&lt;br /&gt;
*** [[Merging two sorted sequences]] (DONE)&lt;br /&gt;
** [[Pattern Matching]]&lt;br /&gt;
*** [[One-dimensional string matching]] (DONE)&lt;br /&gt;
*** [[String matching]] (DONE)&lt;br /&gt;
** [[Sorting]]&lt;br /&gt;
*** [[Sorting based on pairwise comparison]] (DONE)&lt;br /&gt;
*** [[Sorting Sequences of Strings]] (DONE)&lt;br /&gt;
&lt;br /&gt;
=== Coding Basics ===&lt;br /&gt;
* [[Inheritance]]&lt;br /&gt;
* [[Generics]]&lt;br /&gt;
* [[Collections]]&lt;br /&gt;
** [[Iterator]]&lt;br /&gt;
** [[Comparator]]&lt;br /&gt;
&lt;br /&gt;
=== String Matching Algorithms ===&lt;br /&gt;
* [[Simple string matching algorithm]] (DONE)&lt;br /&gt;
* [[String matching based on finite automaton]] (DONE)&lt;br /&gt;
&lt;br /&gt;
=== Sorting Algorithms ===&lt;br /&gt;
* [[Bubble]]&lt;br /&gt;
* [[Insertion sort]]&lt;br /&gt;
* [[Quicksort]]&lt;br /&gt;
* [[Bubblesort]]&lt;br /&gt;
* [[Mergesort]]&lt;br /&gt;
* [[Bucketsort]]&lt;br /&gt;
* [[Selection sort]]&lt;br /&gt;
* [[Bogosort]]&lt;br /&gt;
&lt;br /&gt;
=== Search Algorithms ===&lt;br /&gt;
* [[Binary search]]&lt;br /&gt;
&lt;br /&gt;
=== Auxillary Algorithms ===&lt;br /&gt;
* [[Pivot partitioning by scanning]]&lt;br /&gt;
&lt;br /&gt;
=== Manipulation ===&lt;br /&gt;
* [[Array list: find]]&lt;br /&gt;
* [[Array list: find at position]]&lt;br /&gt;
* [[Array list: insert at head]]&lt;br /&gt;
* [[Array list: insert at position]]&lt;br /&gt;
* [[Array list: number]]&lt;br /&gt;
* [[Array list: remove]]&lt;br /&gt;
* [[Doubly-linked list: insert at position]]&lt;br /&gt;
* [[Doubly-linked list: insert at tail]]&lt;br /&gt;
* [[Doubly-linked list: remove]]&lt;br /&gt;
* [[Find element in sequence iteratively]]&lt;br /&gt;
* [[Find element in sequence recursively]]&lt;br /&gt;
* [[Hashtable: find]]&lt;br /&gt;
* [[Hashtable: insert]]&lt;br /&gt;
&lt;br /&gt;
=== Tree Algorithms ===&lt;br /&gt;
* [[Depth-first search]]&lt;br /&gt;
* [[Breadth-first search]]&lt;br /&gt;
* [[B-tree: find]]&lt;br /&gt;
* [[B-tree: minimum]]&lt;br /&gt;
* [[B-tree: maximum]]&lt;br /&gt;
* [[B-tree: insert]]&lt;br /&gt;
* [[B-tree: insert and rearrange]]&lt;br /&gt;
* [[B-tree: merge two siblings]]&lt;br /&gt;
* [[B-tree: remove]]&lt;br /&gt;
* [[B-tree: shift key to sibling]]&lt;br /&gt;
* [[B-tree: rotate]]&lt;br /&gt;
* [[B-tree: merge]]&lt;br /&gt;
* [[B-tree: split]]&lt;br /&gt;
* [[Binary search tree: find]]&lt;br /&gt;
* [[Binary search tree: minimum]]&lt;br /&gt;
* [[Binary search tree: maximum]]&lt;br /&gt;
* [[Binary search tree: insert]]&lt;br /&gt;
* [[Binary search tree: remove]]&lt;br /&gt;
* [[Binary search tree: remove node]]&lt;br /&gt;
* [[Binary search tree: traverse]]&lt;br /&gt;
&lt;br /&gt;
=== Graph Theory ===&lt;br /&gt;
* [[Directed graph]]&lt;br /&gt;
* [[Bipartite graph|Bipartite graph]] (DONE)&lt;br /&gt;
* [[k-partite graph]]&lt;br /&gt;
* [[Negative paths]]&lt;br /&gt;
&lt;br /&gt;
=== Graph Algorithms ===&lt;br /&gt;
* [[Dijkstra]]&lt;br /&gt;
* [[Kruskal]]&lt;br /&gt;
* [[Prim]]&lt;br /&gt;
* [[Bellman-Ford]] (DONE)&lt;br /&gt;
* [[Floyd-Warshall]]&lt;br /&gt;
* [[Union Find]]&lt;br /&gt;
* [[A*]]&lt;br /&gt;
* [[Alternating paths algorithm]]&lt;br /&gt;
* [[Johnson]]&lt;br /&gt;
* [[Union-find with disjoint trees: find]]&lt;br /&gt;
* [[Union-find with lists: unite]]&lt;br /&gt;
* [[Max-flow min-cut]]&lt;br /&gt;
&lt;br /&gt;
=== Flow Algorithms ===&lt;br /&gt;
* [[Ford-Fulkerson]]&lt;br /&gt;
=== Abstract Data Structures ===&lt;br /&gt;
*[[Network Structures]]&lt;br /&gt;
**[[Graph]]&lt;br /&gt;
**[[Tree]]&lt;br /&gt;
*[[Sequence]]&lt;br /&gt;
**[[Sorted sequence]]&lt;br /&gt;
**[[Bounded priority queue]]&lt;br /&gt;
**[[Linear sequence]]&lt;br /&gt;
**[[Priority queue]]&lt;br /&gt;
**[[Sorted sequence]]&lt;br /&gt;
=== Implementations of Abstract Data Structures  ===&lt;br /&gt;
* [[Linked list]]&lt;br /&gt;
* [[Array list]]&lt;br /&gt;
* [[Binary search tree]]&lt;br /&gt;
* [[Doubly-linked list]]&lt;br /&gt;
* [[Heap as array]] (DONE (Heap as Array))&lt;br /&gt;
* [[Hashtable]]&lt;br /&gt;
* [[Multi-way search tree]]&lt;br /&gt;
* [[Red-black tree]]&lt;br /&gt;
* [[B-tree]]&lt;br /&gt;
&lt;br /&gt;
=== ??? ===&lt;br /&gt;
* [[Min-Max Heaps]]&lt;br /&gt;
* [[First In - First Out]]&lt;br /&gt;
* [[First In - Last Out]]&lt;br /&gt;
* [[Directed Tree]]&lt;br /&gt;
* [[Decision Tree]]&lt;br /&gt;
&lt;br /&gt;
=== Other ===&lt;br /&gt;
* [[Model computer]]&lt;br /&gt;
&lt;br /&gt;
=== Other Algorithms (LOCKED) ===&lt;br /&gt;
* [[B*]]&lt;br /&gt;
* [[Cyclic redundancy check]]&lt;br /&gt;
* [[Euclid]]&lt;br /&gt;
* [[Gauss]]&lt;br /&gt;
* [[Discrete fourier transform]]&lt;br /&gt;
* [[Fast fourier transform]]&lt;br /&gt;
* [[Bresenham]]&lt;br /&gt;
* [[Round robin]]&lt;br /&gt;
* [[Seperate and conquer]]&lt;br /&gt;
* [[Message-Digest algorithm]]&lt;br /&gt;
* [[Secure hash algorithm]]&lt;br /&gt;
* [[Sequent calculus]]&lt;br /&gt;
* [[Resolution calculus]]&lt;br /&gt;
* [[Cocke-Younger-Kasami algorithm]]&lt;br /&gt;
* [[Distance vector routing]]&lt;br /&gt;
* [[Link state routing]]&lt;br /&gt;
* [[Z Buffer algorithm]]&lt;br /&gt;
* [[Marching squares]]&lt;br /&gt;
* [[Marching cubes]]&lt;br /&gt;
* [[Bottom-Up heapsort]]&lt;br /&gt;
* [[Radixsort]]&lt;br /&gt;
* [[Median cut]]&lt;br /&gt;
* [[Pancake sorting]]&lt;br /&gt;
* [[Karnaugh-Veitch diagramm]]&lt;br /&gt;
* [[Delanuay triangulation]]&lt;br /&gt;
* [[Backtracking]]&lt;br /&gt;
* [[Alpha–beta pruning]]&lt;br /&gt;
* [[Beam search]]&lt;br /&gt;
* [[Best-first search]]&lt;br /&gt;
* [[Bidirectional search]]&lt;br /&gt;
* [[Borůvka's algorithm]]&lt;br /&gt;
* [[Branch and bound]]&lt;br /&gt;
* [[D*]]&lt;br /&gt;
* [[Depth-limited search]]&lt;br /&gt;
* [[Edmonds' algorithm]]&lt;br /&gt;
* [[Fringe search]]&lt;br /&gt;
* [[Hill climbing]]&lt;br /&gt;
* [[IDA*]]&lt;br /&gt;
* [[Iterative deepening depth-first search]]&lt;br /&gt;
* [[Jump point search]]&lt;br /&gt;
* [[Lexicographic breadth-first search]]&lt;br /&gt;
* [[SMA*]]&lt;br /&gt;
* [[Uniform-cost search]]&lt;br /&gt;
&lt;br /&gt;
=== Other Data Structures (LOCKED) ===&lt;br /&gt;
* [[Adelson-Velskii and Landis' tree]]&lt;br /&gt;
* [[Patricia-Trie]]&lt;br /&gt;
* [[Suffix Tree]]&lt;br /&gt;
* [[Huffmann Tree]]&lt;br /&gt;
* [[Binary Expression Tree]]&lt;br /&gt;
* [[Hash Set]]&lt;br /&gt;
* [[Incidence Matrix]]&lt;br /&gt;
* [[Voronoi Diagramm]]&lt;br /&gt;
* [[Quad Tree]]&lt;br /&gt;
* [[Oct Tree]]&lt;br /&gt;
* [[kd Tree]]&lt;br /&gt;
* [[Binary space partitioning]]&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Directed_graph&amp;diff=2170</id>
		<title>Directed graph</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Directed_graph&amp;diff=2170"/>
		<updated>2014-11-17T20:12:48Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Definition==&lt;br /&gt;
A directed graph is a graph, where every edge has a direction. More precisely, a directed graph is a pair &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; represents a set of nodes and &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt; a set of arcs. Arcs are ordered pairs of nodes in contrast to unordered pairs of nodes (called edges) in an undirected graph. An arc &amp;lt;math&amp;gt;a = (v, w)&amp;lt;/math&amp;gt; is considered to be directed '''from''' &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; '''to''' &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=K-partite_graph&amp;diff=2169</id>
		<title>K-partite graph</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=K-partite_graph&amp;diff=2169"/>
		<updated>2014-11-17T19:53:33Z</updated>

		<summary type="html">&lt;p&gt;BB91: Created page with &amp;quot;==Definition==  An undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is called '''k-partite''', if there is a partition of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, hereinafter referred to as &amp;lt;math&amp;gt;V=\dot\cup_{i=1...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Definition==&lt;br /&gt;
&lt;br /&gt;
An undirected graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt; is called '''k-partite''', if there is a partition of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, hereinafter referred to as &amp;lt;math&amp;gt;V=\dot\cup_{i=1}^k V_{i}&amp;lt;/math&amp;gt;, such that there is no edge between two nodes that belong to the same partition component &amp;lt;math&amp;gt;V_{i}&amp;lt;/math&amp;gt;. In other words, the following implication must hold:&lt;br /&gt;
:&amp;lt;math&amp;gt;\forall i\in \{1,\ldots,k\}: v \in V_i \wedge w \in V_i \rightarrow \{v,w\} \not\in E&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Remark==&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;k=2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is called [[bipartite graph]].&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Basic_flow_definitions&amp;diff=2116</id>
		<title>Basic flow definitions</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Basic_flow_definitions&amp;diff=2116"/>
		<updated>2014-11-16T11:56:12Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Residual network */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic definitions ==&lt;br /&gt;
&lt;br /&gt;
# [[Basic graph definitions]]&lt;br /&gt;
&lt;br /&gt;
== Basic setting ==&lt;br /&gt;
On this page and all dependent pages, &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; is an [[Basic graph definitions#Directed and undirected graphs|anti-symmetric, simple directed graph]], unless stated otherwise. &lt;br /&gt;
# For &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, there is a nonnegative '''upper bound''' &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# In some flow problems, there is a '''lower bound''' &amp;lt;math&amp;gt;\ell(a)&amp;lt;/math&amp;gt; as well, which need not be nonnegative.&lt;br /&gt;
# In some flow problems, each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; has a '''required balance''' (or '''balance''' for short) &amp;lt;math&amp;gt;b(v)&amp;lt;/math&amp;gt;. We also speak of the '''node balance'''.&lt;br /&gt;
# In some flow problems, there is a real-valued (not necessarily nonnegative) '''cost factor''' &amp;lt;math&amp;gt;c(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
Other node and arc attributes may occur in specific flow problems. Unless stated otherwise, there are no  node or arc attributes except for the upper bounds on arcs.&lt;br /&gt;
&lt;br /&gt;
'''Neutral values of attributes:'''&lt;br /&gt;
When a node or arc is added to a graph, it is sometimes appropriate to set its attributes to neutral values. The neutral values for upper and lower bounds are &amp;lt;math&amp;gt;+\infty&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;-\infty&amp;lt;/math&amp;gt;, respectively. For cost factors and node balances, the neutral value is zero.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
Simplicity and anti-symmetry do not reduce generality in the context of flow problems:&lt;br /&gt;
# If there are two arcs &amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a_2&amp;lt;/math&amp;gt;, say, from &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt;, add a new node &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, replace &amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt; by new arcs &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(u,w)&amp;lt;/math&amp;gt;, transfer the attribute values of &amp;lt;math&amp;gt;a_1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; and set all attributes of &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; and of &amp;lt;math&amp;gt;(u,w)&amp;lt;/math&amp;gt; to their neutral values.&lt;br /&gt;
# If there is a loop &amp;lt;math&amp;gt;(v,v)&amp;lt;/math&amp;gt;, add a new node &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, replace &amp;lt;math&amp;gt;(v,v)&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt;, and set the attribute values analogously to the case of parallel arcs.&lt;br /&gt;
# If &amp;lt;math&amp;gt;(v,w),(w,v)\in A&amp;lt;/math&amp;gt; add a new node &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt;, replace  &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; by new arcs &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;(u,w)&amp;lt;/math&amp;gt;, and set the attribute values analogously to the case of parallel arcs.&lt;br /&gt;
&lt;br /&gt;
'''Integrality assumption:'''&lt;br /&gt;
All numerical node and arc attributes are integral.&lt;br /&gt;
&lt;br /&gt;
In the context of flow problems, this assumption does not reduce generality, either: Choosing a sufficiently small &amp;lt;math&amp;gt;\delta&amp;gt;0&amp;lt;/math&amp;gt; and replacing each attribute value by the nearest integral multiple of &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; has a negligible impact on the output.&lt;br /&gt;
&lt;br /&gt;
== Feasible flow ==&lt;br /&gt;
&lt;br /&gt;
'''Capacity constraints:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; be an arc weighting, that is, a value &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; is given for each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
# We say that &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; fulfills the '''capacity constraints''' if &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If lower bounds &amp;lt;math&amp;gt;\ell&amp;lt;/math&amp;gt; are given, the condition &amp;lt;math&amp;gt;f(a)\geq 0&amp;lt;/math&amp;gt; is to be replaced by &amp;lt;math&amp;gt;f(a)\geq\ell(a)&amp;lt;/math&amp;gt;. In particular, &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; may be negative if &amp;lt;math&amp;gt;\ell(a)&amp;lt;/math&amp;gt; is so.&lt;br /&gt;
&lt;br /&gt;
'''Flow conservation condition:'''&lt;br /&gt;
Let &amp;lt;math&amp;gt;W\subseteq V&amp;lt;/math&amp;gt;.&lt;br /&gt;
# An arc weighting fulfills the flow conservation condition with respect to &amp;lt;math&amp;gt;W&amp;lt;/math&amp;gt; if for all nodes &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt;: &amp;lt;math&amp;gt;\sum_{w\in V\atop(v,w)\in A}f(v,w)-\sum_{w\in V\atop(w,v)\in A}f(w,v)=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If there are balance values &amp;lt;math&amp;gt;b(v)&amp;lt;/math&amp;gt; for all nodes &amp;lt;math&amp;gt;v\in V\setminus W&amp;lt;/math&amp;gt;, the right-hand side of this condition is not zero but &amp;lt;math&amp;gt;b(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A '''feasible flow''' (or '''flow''' for short) with respect to &amp;lt;math&amp;gt;W\subseteq V&amp;lt;/math&amp;gt; is an arc weighting that satisfies the capacity constraints and the flow conservation condition.&lt;br /&gt;
&lt;br /&gt;
== Preflow ==&lt;br /&gt;
&lt;br /&gt;
# Preflows generalize feasible flows as follows: Instead of an equation, the following inequality is to be fulfilled for each &amp;lt;math&amp;gt;v\in V\setminus W&amp;lt;/math&amp;gt;: &amp;lt;math&amp;gt;\sum_{w:(v,w)\in A}f(v,w)-\sum_{w:(w,v)\in A}f(w,v)\geq 0&amp;lt;/math&amp;gt; (resp., &amp;lt;math&amp;gt;\geq b(v)&amp;lt;/math&amp;gt;, if node balances are given).&lt;br /&gt;
# The '''excess''' of &amp;lt;math&amp;gt;v\in V\setminus W&amp;lt;/math&amp;gt; is the value of the left-hand side of that inequality. A node is '''active''' if its excess is strictly positive.&lt;br /&gt;
&lt;br /&gt;
== Flow value ==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;S,T\in V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;S\cap T=\emptyset&amp;lt;/math&amp;gt;, and let &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; be a flow with respect to &amp;lt;math&amp;gt;S\cup T&amp;lt;/math&amp;gt;. The '''flow value''' &amp;lt;math&amp;gt;v(f)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined by&lt;br /&gt;
:&amp;lt;math&amp;gt;v(f):=\sum_{s\in S,v\in V\setminus S\atop(s,v)\in A}f(s,v)-\sum_{s\in S,v\in V\setminus S\atop(v,s)\in A}f(v,s)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
A straightforward induction on &amp;lt;math&amp;gt;k\geq|S|&amp;lt;/math&amp;gt; shows that for all partitions &amp;lt;math&amp;gt;(V_S,V_T)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;|V_S|=k&amp;lt;/math&amp;gt;, it is&lt;br /&gt;
:&amp;lt;math&amp;gt;v(f)=\sum_{v\in V_S,w\in V_T\atop(v,w)\in A}f(v,w)-\sum_{v\in V_S,w\in V_T\atop(w,v)\in A}f(w,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
In particular, mirror-symmetrically to the definition of &amp;lt;math&amp;gt;v(f)&amp;lt;/math&amp;gt;, it is&lt;br /&gt;
:&amp;lt;math&amp;gt;v(f)=\sum_{v\in V\setminus T,t\in T\atop(v,t)\in A}f(v,t)-\sum_{v\in V\setminus T,t\in T\atop(t,v)\in A}f(t,v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Residual network ==&lt;br /&gt;
&lt;br /&gt;
The '''residual network''' &amp;lt;math&amp;gt;(G_f,u_f)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;(G,u)&amp;lt;/math&amp;gt; with respect to an arc weighting &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is defined as follows: It is &amp;lt;math&amp;gt;G_f=(V,A_f)&amp;lt;/math&amp;gt;, and for each arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt;, we have:&lt;br /&gt;
# &amp;lt;math&amp;gt;(v,w)\in A_f&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;u_f(v,w)=u(v,w)-f(v,w)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;u(v,w)-f(v,w)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# &amp;lt;math&amp;gt;(w,v)\in A_f&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;u_f(w,v)=f(v,w)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;f(v,w)&amp;gt;0&amp;lt;/math&amp;gt;.&lt;br /&gt;
The value &amp;lt;math&amp;gt;u_f(a)&amp;lt;/math&amp;gt; of an arc &amp;lt;math&amp;gt;a\in A_f&amp;lt;/math&amp;gt;is called the '''residual capacity''' of &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
Changes of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and changes of &amp;lt;math&amp;gt;u_f&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G_f&amp;lt;/math&amp;gt; are equivalent in an obvious way. Since &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is anti-symmetric, this equivalence is one-to-one. So, the view on &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is exchangeable with the view on &amp;lt;math&amp;gt;G_f&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;u_f&amp;lt;/math&amp;gt;. We will adopt both views simultaneously in the presentation and discussion of the individual algorithms. An implementation of an algorithm may be based on &amp;lt;math&amp;gt;(G,f)&amp;lt;/math&amp;gt; or on &amp;lt;math&amp;gt;(G_f,u_f)&amp;lt;/math&amp;gt; or even on both representations simultaneously.&lt;br /&gt;
&lt;br /&gt;
== Flow-augmenting paths and saturated arcs ==&lt;br /&gt;
&lt;br /&gt;
A '''flow-augmenting path''' (or '''augmenting path''' for short) from some node &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt; to some node &amp;lt;math&amp;gt;t\in V&amp;lt;/math&amp;gt; is an [[Basic graph definitions#Paths|ordinary path]] in the residual network &amp;lt;math&amp;gt;G_f&amp;lt;/math&amp;gt;. Equivalently, a flow-augmenting path is a [[Basic graph definitions#Paths|generalized path]] in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; such that:&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)&amp;lt;u(a)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a forward arc;&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)&amp;gt;0&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a backward arc.&lt;br /&gt;
An arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is '''saturated'''&lt;br /&gt;
# in forward direction if &amp;lt;math&amp;gt;f(a)=u(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# in backward direction if &amp;lt;math&amp;gt;f(a)=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
We say that an arc of a path is '''saturated''' if it is saturated in the direction of this path. Clearly, a path is augmenting if, and only if, it contains no saturated arc in its direction.&lt;br /&gt;
&lt;br /&gt;
== Augmenting along a path ==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; denote some flow-augmenting path in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, and let &amp;lt;math&amp;gt;\varepsilon&amp;gt;0&amp;lt;/math&amp;gt; such that&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)+\varepsilon\leq u(a)&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a forward arc;&lt;br /&gt;
# &amp;lt;math&amp;gt;f(a)-\varepsilon\geq 0&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; is a backward arc.&lt;br /&gt;
In the residual network &amp;lt;math&amp;gt;(G_f,u_f)&amp;lt;/math&amp;gt;, '''augmenting''' &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; along the [[Basic graph definitions#Paths|ordinary path]] induced by &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; means reducing all residual capacities by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt;. Equivalently, for each arc &amp;lt;math&amp;gt;a \in A&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, this means:  &lt;br /&gt;
# Increase the flow value by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is a forward arc on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Decrease the flow value by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is a backward arc on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
Obviously, the capacity constraints are preserved. The flow conservation conditions are preserved at every [[Basic graph definitions#Paths|internal node]] of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. To see that, let &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; be such an internal node, and let &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; denote the immediate predecessor and successor of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, respectively. Basically, there are four cases:&lt;br /&gt;
*Either &amp;lt;math&amp;gt;(u,v)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as a forward arc or &amp;lt;math&amp;gt;(v,u)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;  as a backward arc.&lt;br /&gt;
*Either &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as a forward arc or &amp;lt;math&amp;gt;(w,v)&amp;lt;/math&amp;gt; is on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; as a backward arc.&lt;br /&gt;
It is easy to check preservation of the flow conservation conditions at &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; for each of these four cases.&lt;br /&gt;
&lt;br /&gt;
'''Augmenting up to saturation:'''&lt;br /&gt;
Again, let &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; denote some flow-augmenting path.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;\varepsilon_1&amp;gt;0&amp;lt;/math&amp;gt; denote the minimum of the values &amp;lt;math&amp;gt;c(a)-f(a)&amp;lt;/math&amp;gt; on all forward arcs of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;\varepsilon_2&amp;gt;0&amp;lt;/math&amp;gt; denote the minimum of the values &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; on all backward arcs of &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; denote the minimum of &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\varepsilon_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
Augmenting the flow &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; along &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;\varepsilon&amp;lt;/math&amp;gt; yields at least one saturated arc.&lt;br /&gt;
&lt;br /&gt;
== Cuts and saturated cuts ==&lt;br /&gt;
&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; be a directed graph and &amp;lt;math&amp;gt;s,t\in V&amp;lt;/math&amp;gt;. An &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-'''cut''' (or '''cut''' for short) is a bipartition &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;s\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t\in T&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; be real values such that &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt; (&amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; need not be a flow here). A cut &amp;lt;math&amp;gt;(S,T)&amp;lt;/math&amp;gt; is '''saturated''' if:&lt;br /&gt;
## &amp;lt;math&amp;gt;f(v,w)=u(v,w)&amp;lt;/math&amp;gt; for every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v\in S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in T&amp;lt;/math&amp;gt;.&lt;br /&gt;
## &amp;lt;math&amp;gt;f(v,w)=0&amp;lt;/math&amp;gt; for every arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v\in T&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in S&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Valid distance labeling ==&lt;br /&gt;
&lt;br /&gt;
'''Definition:'''&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; be a directed graph, and for each arc &amp;lt;math&amp;gt;a\in A&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;u(a)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(a)&amp;lt;/math&amp;gt; be defined such that &amp;lt;math&amp;gt;0\leq f(a)\leq u(a)&amp;lt;/math&amp;gt;. An assignment of a value &amp;lt;math&amp;gt;d(v)&amp;lt;/math&amp;gt; to each node &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; is a '''valid distance labeling''' if the following two conditions ar fulfilled:&lt;br /&gt;
## It is &amp;lt;math&amp;gt;d(t)=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
## For each arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; in the residual network, it is &amp;lt;math&amp;gt;d(v)\leq d(w)+1&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If even &amp;lt;math&amp;gt;d(v)=d(w)+1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is called an '''admissible arc'''.&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=1866</id>
		<title>Kosaraju</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Kosaraju&amp;diff=1866"/>
		<updated>2014-11-09T14:59:10Z</updated>

		<summary type="html">&lt;p&gt;BB91: /* Correctness */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Strongly connected components]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' loop&lt;br /&gt;
&lt;br /&gt;
== Abstract View ==&lt;br /&gt;
&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, the output order is parenthetical.&lt;br /&gt;
# Invert the output order of the nodes.&lt;br /&gt;
# Let &amp;lt;math&amp;gt;G^t=(V,A^t)&amp;lt;/math&amp;gt; be the [[Basic graph definitions#Transpose of a graph|transpose]] of &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Apply a [[repeated depth-first search]] to &amp;lt;math&amp;gt;G^t&amp;lt;/math&amp;gt; with a modification: The order in which the nodes are considered as potential start nodes is the inverted parenthetical order from step 2. &lt;br /&gt;
# The node sets from the individual applications of [[Depth-first search|DFS]] inside step 4 are exactly the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Correctness ==&lt;br /&gt;
&lt;br /&gt;
First note that the transposition of all arcs does not change the SCC of a graph, so step 4 indeed processes the SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
[[File:CondensedGraphKosaraju.jpg|200px|thumb|right|Construction of the condensed graph (example)]]&lt;br /&gt;
Consider the condensed graph &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; whose nodes are these SCC, and there is an arc from an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt; if, and only if, there is at least one arc in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; from some node in &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; to some node in &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt;. This condensed graph is acyclic because all nodes in all SCC on a cycle would be mutually reachable from each other in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; and their union would consequently form a single larger SCC contradicting the construction of the condensed graph.&lt;br /&gt;
&lt;br /&gt;
In step 1, each [[Depth-first search|DFS]] run either meets ''all'' nodes of an SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; or ''none'' of the nodes of this SCC. More specifically, all nodes in the same SCC as the start node and in all SCC reachable from that SCC, except for the SCC processed in previous [[Depth-first search|DFS]] runs.&lt;br /&gt;
&lt;br /&gt;
It is easy to see that all nodes of an SCC are finished consecutively (because of the parenthetical order); that is, all nodes of an SCC form a connected  subsequence in the output sequence of step 1. In particular, it does not matter in step 4 which node of an SCC is chosen as a start node for a [[Depth-first search|DFS]] run. If an SCC &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from an SCC &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, then the nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; appear before the nodes of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in parenthetical order. Equivalently, the nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; appear ''after'' the nodes of &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; in the reverse order on which step 4 is based.&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; be two SCC of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. Since each SCC is processed exhaustively or not at all in a  [[Depth-first search|DFS]] run, it suffices to show that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are not processed within the same run of step 4. Suppose for a contradiction that &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_j&amp;lt;/math&amp;gt; are processed in the same [[Depth-first search|DFS]] run in step 4 (not necessarily in the same run in step 1). Let &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; be the SCC to which the start node of that run belongs (possibly &amp;lt;math&amp;gt;k=i&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;k=j&amp;lt;/math&amp;gt;). Without loss of generality, suppose &amp;lt;math&amp;gt;k\neq i&amp;lt;/math&amp;gt;. Then &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G'&amp;lt;/math&amp;gt;; in other words, &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. However, then the nodes of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; have higher finishing times than the nodes of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;, so some node of &amp;lt;math&amp;gt;C_i&amp;lt;/math&amp;gt; had been chosen as a start node before any node of &amp;lt;math&amp;gt;C_k&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The asymptotic complexity is in &amp;lt;math&amp;gt;\Theta(|V|+|A|)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Follows immediately from the linear asymptotic complexity of [[Repeated depth-first search|repeated DFS]].&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 STRONGLY-CONNECTED-COMPONENTS(''D'')&lt;br /&gt;
 1 call '''DFS'''(''D'') to compute finishing times ''f''[v] for each vertex ''v'' &amp;amp;isin; ''V''&lt;br /&gt;
 2 compute ''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt; (w.r.t. step 3)&lt;br /&gt;
 3 call '''DFS'''(''D''&amp;lt;sup&amp;gt;''T''&amp;lt;/sup&amp;gt;), but in the main loop of '''DFS''', consider the vertices in order of decreasing ''f''[v] as computed in step 1&lt;br /&gt;
 4 output the vertices of each tree in the '''DFS''' forest of step 3 as a separate strongly connected component&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:CondensedGraphKosaraju.jpg&amp;diff=1865</id>
		<title>File:CondensedGraphKosaraju.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:CondensedGraphKosaraju.jpg&amp;diff=1865"/>
		<updated>2014-11-09T14:52:30Z</updated>

		<summary type="html">&lt;p&gt;BB91: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>BB91</name></author>
	</entry>
</feed>