<?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=Mahn89</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=Mahn89"/>
	<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/Special:Contributions/Mahn89"/>
	<updated>2026-04-11T00:40:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.38.4</generator>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-Flow_Problems&amp;diff=2428</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=2428"/>
		<updated>2014-12-02T13:26:16Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Generalizations */&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>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-Flow_Problems&amp;diff=2427</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=2427"/>
		<updated>2014-12-02T13:23:30Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Generalizations */&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>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2426</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=2426"/>
		<updated>2014-12-02T13:02:18Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* 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>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Edmonds_max_branching_ani_10000.gif&amp;diff=2425</id>
		<title>File:Edmonds max branching ani 10000.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Edmonds_max_branching_ani_10000.gif&amp;diff=2425"/>
		<updated>2014-12-02T12:51:22Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Edmonds_max_branching_ani.gif&amp;diff=2424</id>
		<title>File:Edmonds max branching ani.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Edmonds_max_branching_ani.gif&amp;diff=2424"/>
		<updated>2014-12-02T12:49:31Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: Mahn89 uploaded a new version of &amp;amp;quot;File:Edmonds max branching ani.gif&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2380</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=2380"/>
		<updated>2014-11-27T11:03:48Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* 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.gif|mini|framed||right|''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>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2379</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=2379"/>
		<updated>2014-11-27T11:01:02Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* 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.gif|miniatur|right|''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>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Branching_by_Edmonds&amp;diff=2378</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=2378"/>
		<updated>2014-11-27T10:57:13Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* 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.gif|350px|thumb|right|''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>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Edmonds_max_branching_ani.gif&amp;diff=2376</id>
		<title>File:Edmonds max branching ani.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Edmonds_max_branching_ani.gif&amp;diff=2376"/>
		<updated>2014-11-27T09:47:04Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Max-Flow_Problems&amp;diff=2375</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=2375"/>
		<updated>2014-11-25T14:38:04Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Generalizations */&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>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Maxflowmultiplesource.png&amp;diff=2374</id>
		<title>File:Maxflowmultiplesource.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Maxflowmultiplesource.png&amp;diff=2374"/>
		<updated>2014-11-25T14:36:06Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2113</id>
		<title>Eulerian cycle</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2113"/>
		<updated>2014-11-12T20:57:01Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Historical Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
&lt;br /&gt;
# A '''eulerian cycle''' is an [[Basic graph definitions#Cycles|ordinary cycle]] in a directed or undirected graph that contains each edge/arc exactly once.&lt;br /&gt;
# A directed or undirected graph is called '''eulerian''' if it admits a eulerian cycle.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
It is easy to see (and follows from the [[Classical eulerian cycle algorithm|classical algorithm]]) that a graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is eulerian if, and only if:&lt;br /&gt;
# Undirected case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is connected, and each node has even degree.&lt;br /&gt;
# Directed case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is strongly connected, and for each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the indegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; equals the outdegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A strongly connected directed or connected undirected graph.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A eulerian cycle as an alternating sequence of nodes and edges/arcs or, alternatively, the (correct) message that the graph is not eulerian.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
[[Classical eulerian cycle algorithm]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Historical Approach ==&lt;br /&gt;
&lt;br /&gt;
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and prefigured the idea of topology. The problem was to find a walk through the city that would cross each bridge once and only once. Euler reformulate the problem in abstracts terms and so he replaces each land mass with an abstract node, aka ''vertex'', and each brigde with an abstract connection, aka ''edge''.&lt;br /&gt;
[[File:Eulerkonigsberg.png]]&lt;br /&gt;
&lt;br /&gt;
Euler observes that during any walk in the graph, the number of times one enters a vertex equals the number of times one leaves it. It follows that, for every vertex (except start and finish), the number of edges touches that vertex must be even. With this studies, Euler shows that a necessary condition for an ''Eulerian walk'' is that&lt;br /&gt;
* the graph is connected and&lt;br /&gt;
* have exactly zero or two nodes of odd degree.&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2112</id>
		<title>Eulerian cycle</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2112"/>
		<updated>2014-11-12T20:37:42Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Historical Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
&lt;br /&gt;
# A '''eulerian cycle''' is an [[Basic graph definitions#Cycles|ordinary cycle]] in a directed or undirected graph that contains each edge/arc exactly once.&lt;br /&gt;
# A directed or undirected graph is called '''eulerian''' if it admits a eulerian cycle.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
It is easy to see (and follows from the [[Classical eulerian cycle algorithm|classical algorithm]]) that a graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is eulerian if, and only if:&lt;br /&gt;
# Undirected case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is connected, and each node has even degree.&lt;br /&gt;
# Directed case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is strongly connected, and for each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the indegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; equals the outdegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A strongly connected directed or connected undirected graph.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A eulerian cycle as an alternating sequence of nodes and edges/arcs or, alternatively, the (correct) message that the graph is not eulerian.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
[[Classical eulerian cycle algorithm]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Historical Approach ==&lt;br /&gt;
&lt;br /&gt;
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and prefigured the idea of topology. The problem was to find a walk through the city that would cross each bridge once and only once. Euler reformulate the problem in abstracts terms and so he replaces each land mass with an abstract node, aka ''vertex'', and each brigde with an abstract connection, aka ''edge''.&lt;br /&gt;
[[File:Eulerkonigsberg.png]]&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Eulerkonigsberg.png&amp;diff=2111</id>
		<title>File:Eulerkonigsberg.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Eulerkonigsberg.png&amp;diff=2111"/>
		<updated>2014-11-12T20:35:27Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2110</id>
		<title>Eulerian cycle</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2110"/>
		<updated>2014-11-12T19:37:22Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
&lt;br /&gt;
# A '''eulerian cycle''' is an [[Basic graph definitions#Cycles|ordinary cycle]] in a directed or undirected graph that contains each edge/arc exactly once.&lt;br /&gt;
# A directed or undirected graph is called '''eulerian''' if it admits a eulerian cycle.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
It is easy to see (and follows from the [[Classical eulerian cycle algorithm|classical algorithm]]) that a graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is eulerian if, and only if:&lt;br /&gt;
# Undirected case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is connected, and each node has even degree.&lt;br /&gt;
# Directed case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is strongly connected, and for each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the indegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; equals the outdegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A strongly connected directed or connected undirected graph.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A eulerian cycle as an alternating sequence of nodes and edges/arcs or, alternatively, the (correct) message that the graph is not eulerian.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
[[Classical eulerian cycle algorithm]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Historical Approach ==&lt;br /&gt;
&lt;br /&gt;
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and prefigured the idea of topology. The problem was to find a walk through the city that would cross each bridge once and only once. Euler reformulate the problem in abstracts terms and so he replaces each land mass with an abstract node, aka ''vertex'', and each brigde with an abstract connection, aka ''edge''.&lt;br /&gt;
TBC...&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2109</id>
		<title>Eulerian cycle</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2109"/>
		<updated>2014-11-12T19:01:11Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Historical Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
&lt;br /&gt;
# A '''eulerian cycle''' is an [[Basic graph definitions#Cycles|ordinary cycle]] in a directed or undirected graph that contains each edge/arc exactly once.&lt;br /&gt;
# A directed or undirected graph is called '''eulerian''' if it admits a eulerian cycle.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
It is easy to see (and follows from the [[Classical eulerian cycle algorithm|classical algorithm]]) that a graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is eulerian if, and only if:&lt;br /&gt;
# Undirected case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is connected, and each node has even degree.&lt;br /&gt;
# Directed case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is strongly connected, and for each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the indegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; equals the outdegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A strongly connected directed or connected undirected graph.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A eulerian cycle as an alternating sequence of nodes and edges/arcs or, alternatively, the (correct) message that the graph is not eulerian.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
[[Classical eulerian cycle algorithm]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Historical Approach ==&lt;br /&gt;
&lt;br /&gt;
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and prefigured the idea of topology. The problem was to find a walk through the city that would cross each bridge once and only once. Euler reformulate the problem in abstracts terms. So Euler replaces each land mass with an abstract node, aka ''vertex'', and each brigde with an abstract connection, aka ''edge''.&lt;br /&gt;
TBC...&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2099</id>
		<title>Eulerian cycle</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2099"/>
		<updated>2014-11-12T14:52:47Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
&lt;br /&gt;
# A '''eulerian cycle''' is an [[Basic graph definitions#Cycles|ordinary cycle]] in a directed or undirected graph that contains each edge/arc exactly once.&lt;br /&gt;
# A directed or undirected graph is called '''eulerian''' if it admits a eulerian cycle.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
It is easy to see (and follows from the [[Classical eulerian cycle algorithm|classical algorithm]]) that a graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is eulerian if, and only if:&lt;br /&gt;
# Undirected case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is connected, and each node has even degree.&lt;br /&gt;
# Directed case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is strongly connected, and for each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the indegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; equals the outdegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A strongly connected directed or connected undirected graph.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A eulerian cycle as an alternating sequence of nodes and edges/arcs or, alternatively, the (correct) message that the graph is not eulerian.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
[[Classical eulerian cycle algorithm]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Historical Approach ==&lt;br /&gt;
&lt;br /&gt;
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and prefigured the idea of topology. The problem was to find a walk through the city that would cross each bridge once and only once. Euler reformulate the problem in abstracts terms (laying the foundation of ''graph theory''). So Euler replaces each land mass with an abstract node, aka ''vertex'', and each brigde with an abstract connection, aka ''edge''.&lt;br /&gt;
TBC...&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2097</id>
		<title>Eulerian cycle</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Eulerian_cycle&amp;diff=2097"/>
		<updated>2014-11-12T14:51:48Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
&lt;br /&gt;
# A '''eulerian cycle''' is an [[Basic graph definitions#Cycles|ordinary cycle]] in a directed or undirected graph that contains each edge/arc exactly once.&lt;br /&gt;
# A directed or undirected graph is called '''eulerian''' if it admits a eulerian cycle.&lt;br /&gt;
&lt;br /&gt;
'''Remark:'''&lt;br /&gt;
It is easy to see (and follows from the [[Classical eulerian cycle algorithm|classical algorithm]]) that a graph &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is eulerian if, and only if:&lt;br /&gt;
# Undirected case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is connected, and each node has even degree.&lt;br /&gt;
# Directed case: &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; is strongly connected, and for each node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, the indegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; equals the outdegree of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A strongly connected directed or connected undirected graph.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A eulerian cycle as an alternating sequence of nodes and edges/arcs or, alternatively, the (correct) message that the graph is not eulerian.&lt;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
[[Classical eulerian cycle algorithm]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Historical Approach ==&lt;br /&gt;
&lt;br /&gt;
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler in 1735 laid the foundations of graph theory and prefigured the idea of topology. The problem was to find a walk through the city that would cross each bridge once and only once. Euler reformulate the oriblem in abstracts terms (laying the foundation of ''graph theory''). So Euler replaces each land mann with an abstract node, aka ''vertex'', and each brigde with an abstract connection, aka ''edge''.&lt;br /&gt;
TBC...&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=2094</id>
		<title>Sorting Algorithms</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=2094"/>
		<updated>2014-11-12T14:21:33Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General Information ==&lt;br /&gt;
&lt;br /&gt;
The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.&lt;br /&gt;
&lt;br /&gt;
Instead of numbers you can sort any data, e.g. strings. There must be a relation between the elements of the set, so to say, an ordering relation &amp;lt;math&amp;gt; \leq &amp;lt;/math&amp;gt; has to be defined.&lt;br /&gt;
&lt;br /&gt;
Often, the data is a set of complex data types, that has to be sorted by a special criteria. For example you have a set of person descriptions to be sorted by the birth dates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n \in \N&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = a_0, \dots, a_{n-1}&amp;lt;/math&amp;gt; a finit sequence with &amp;lt;math&amp;gt;a_i \in \N \quad (i = 0, \dots, n-1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''sorting problem'' is to find a sequence &amp;lt;math&amp;gt;a_{\varphi (0)}, \dots, a_{\varphi (n-1)}&amp;lt;/math&amp;gt; with folloing constraints:&lt;br /&gt;
:* &amp;lt;math&amp;gt;a_{\varphi(i)} \leq a_{\varphi(j)} \quad \forall i,j \in \{0, \dots, n-1\}, i &amp;lt; j&amp;lt;/math&amp;gt;&lt;br /&gt;
:* the mapping &amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a permutation of the index set &amp;lt;math&amp;gt;\{0, \dots, n-1\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n = 8&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = 3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
:{|&lt;br /&gt;
|style=&amp;quot;width: 4em&amp;quot;| &amp;lt;math&amp;gt;i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;\varphi(i):&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;2 \ 6 \ 5 \ 0 \ 4 \ 3 \ 7 \ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_{\varphi(i)}:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;1 \ 2 \ 3 \ 3 \ 3 \ 4 \ 6 \ 8&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Important algorithms ==&lt;br /&gt;
* [[Bogosort]]&lt;br /&gt;
* [[Bubble]]&lt;br /&gt;
* [[Bubblesort]]&lt;br /&gt;
* [[Bucketsort]]&lt;br /&gt;
* [[Insertion sort]]&lt;br /&gt;
* [[Mergesort]]&lt;br /&gt;
* [[Quicksort]]&lt;br /&gt;
* [[Selection sort]]&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=2021</id>
		<title>Sorting Algorithms</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=2021"/>
		<updated>2014-11-10T14:29:21Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.&lt;br /&gt;
&lt;br /&gt;
Instead of numbers you can sort any data, e.g. strings. There must be a relation between the elements of the set, so to say, an ordering relation &amp;lt;math&amp;gt; \leq &amp;lt;/math&amp;gt; has to be defined.&lt;br /&gt;
&lt;br /&gt;
Often, the data is a set of complex data types, that has to be sorted by a special criteria. For example you have a set of person descriptions to be sorted by the birth dates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n \in \N&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = a_0, \dots, a_{n-1}&amp;lt;/math&amp;gt; a finit sequence with &amp;lt;math&amp;gt;a_i \in \N \quad (i = 0, \dots, n-1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''sorting problem'' is to find a sequence &amp;lt;math&amp;gt;a_{\varphi (0)}, \dots, a_{\varphi (n-1)}&amp;lt;/math&amp;gt; with folloing constraints:&lt;br /&gt;
:* &amp;lt;math&amp;gt;a_{\varphi(i)} \leq a_{\varphi(j)} \quad \forall i,j \in \{0, \dots, n-1\}, i &amp;lt; j&amp;lt;/math&amp;gt;&lt;br /&gt;
:* the mapping &amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a permutation of the index set &amp;lt;math&amp;gt;\{0, \dots, n-1\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n = 8&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = 3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
:{|&lt;br /&gt;
|style=&amp;quot;width: 4em&amp;quot;| &amp;lt;math&amp;gt;i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;\varphi(i):&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;2 \ 6 \ 5 \ 0 \ 4 \ 3 \ 7 \ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_{\varphi(i)}:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;1 \ 2 \ 3 \ 3 \ 3 \ 4 \ 6 \ 8&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Important algorithms ==&lt;br /&gt;
* [[Bogosort]]&lt;br /&gt;
* [[Bubble]]&lt;br /&gt;
* [[Bubblesort]]&lt;br /&gt;
* [[Bucketsort]]&lt;br /&gt;
* [[Insertion sort]]&lt;br /&gt;
* [[Mergesort]]&lt;br /&gt;
* [[Quicksort]]&lt;br /&gt;
* [[Selection sort]]&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Quicksort&amp;diff=1868</id>
		<title>Quicksort</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Quicksort&amp;diff=1868"/>
		<updated>2014-11-09T15:32:28Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Complexity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Sorting Algorithms]]&lt;br /&gt;
[[Category:Divide and Conquer]]&lt;br /&gt;
&amp;lt;div class=&amp;quot;plainlinks&amp;quot; style=&amp;quot;float:right;margin:0 0 5px 5px; border:1px solid #AAAAAA; width:auto; padding:1em; margin: 0px 0px 1em 1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.8em;font-weight:bold;text-align: center;margin:0.2em 0 1em 0&amp;quot;&amp;gt;Quick Sort&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 1em 0; text-align:center&amp;quot;&amp;gt;whatever&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 .5em 0;text-align:center&amp;quot;&amp;gt;[[File:olw_logo1.png|20px]][https://openlearnware.tu-darmstadt.de/#!/resource/quick-sort-1945 Openlearnware]&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
'''Algorithmic problem:''' [[Sorting based on pairwise comparison]]&lt;br /&gt;
&lt;br /&gt;
'''Type of algorithm:''' recursion&lt;br /&gt;
&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' After a recursive call, the input sequence of this recursive call is sorted.&lt;br /&gt;
&lt;br /&gt;
'''Variant:''' In each recursive call, the sequence of the callee is strictly shorter than that of the caller.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:''' The sequence is empty or a singleton.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
&lt;br /&gt;
'''Abstract view:''' Nothing to do on an empty sequence or a singleton.&lt;br /&gt;
&lt;br /&gt;
'''Implementation:''' Ditto.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Empty sequences and singletons are trivially sorted.&lt;br /&gt;
&lt;br /&gt;
== Induction step ==&lt;br /&gt;
&lt;br /&gt;
=== Abstract view: ===&lt;br /&gt;
# Choose a pivot value &amp;lt;math&amp;gt;p \in [min\{x|x \in S\},\dots,max\{x|x \in S\}]&amp;lt;/math&amp;gt; (note that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; is not required to be an element of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Partition &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; into sequences, &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;S_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_3&amp;lt;/math&amp;gt;, such that &amp;lt;math&amp;gt;x &amp;lt; p&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;x \in S_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x = p&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;x \in S_2&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;x &amp;gt; p&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;x \in S_3&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Sort &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_3&amp;lt;/math&amp;gt; recursively.&lt;br /&gt;
# The concatenation of all three lists, &amp;lt;math&amp;gt;S_1 \| S_2 \| S_3&amp;lt;/math&amp;gt;, is the result of the algorithm.&lt;br /&gt;
&lt;br /&gt;
=== Implementation: ===&lt;br /&gt;
&lt;br /&gt;
# Chose &amp;lt;math&amp;gt;p \in [min\{x|x \in S\},\dots,max\{x|x \in S\}]&amp;lt;/math&amp;gt; according to some pivoting rule.&lt;br /&gt;
# &amp;lt;math&amp;gt;S_1 := S_2 := S_3 := \emptyset&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;x \in S&amp;lt;/math&amp;gt;, append &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; to&lt;br /&gt;
## &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;x &amp;lt; p&amp;lt;/math&amp;gt;,&lt;br /&gt;
## &amp;lt;math&amp;gt;S_2&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;x = p&amp;lt;/math&amp;gt;,&lt;br /&gt;
## &amp;lt;math&amp;gt;S_3&amp;lt;/math&amp;gt; if &amp;lt;math&amp;gt;x &amp;gt; p&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Call Quicksort on &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;S_1'&amp;lt;/math&amp;gt;&lt;br /&gt;
# Call Quicksort on &amp;lt;math&amp;gt;S_3&amp;lt;/math&amp;gt; giving &amp;lt;math&amp;gt;S_3'&amp;lt;/math&amp;gt;&lt;br /&gt;
# Return &amp;lt;math&amp;gt;S_1' \| S_2' \| S_3'&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Correctness: ===&lt;br /&gt;
&lt;br /&gt;
By induction hypothesis, &amp;lt;math&amp;gt;S_1'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_3'&amp;lt;/math&amp;gt; are sorted permutations of &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_3&amp;lt;/math&amp;gt;, respectively. In particular &amp;lt;math&amp;gt;S_1' \| S_2 \| S_3'&amp;lt;/math&amp;gt; is a permutation of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;. To see that this permutation is sorted, let &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; be two members of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; immediately succeeds &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; in the resulting sequence &amp;lt;math&amp;gt;S_1' \| S_2 \| S_3'&amp;lt;/math&amp;gt;. We have to show &amp;lt;math&amp;gt;x \leq y&amp;lt;/math&amp;gt;.&lt;br /&gt;
# If &amp;lt;math&amp;gt;x,y \in S_1'&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;x,y \in S_3'&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x \leq y&amp;lt;/math&amp;gt; resultes from the induction hypothesis.&lt;br /&gt;
# On the other hand, if &amp;lt;math&amp;gt;x,y \in S_2&amp;lt;/math&amp;gt;. It is &amp;lt;math&amp;gt;x = y = p&amp;lt;/math&amp;gt;, which trivially implies &amp;lt;math&amp;gt;x \leq y&amp;lt;/math&amp;gt;&lt;br /&gt;
# Finally, for following cases, &amp;lt;math&amp;gt;x \leq y&amp;lt;/math&amp;gt; is implied by the specific way of partitioning &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;S_1'&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;S_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_3'&amp;lt;/math&amp;gt;:&lt;br /&gt;
## &amp;lt;math&amp;gt;x \in S_1'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y \in S_2&amp;lt;/math&amp;gt;&lt;br /&gt;
## &amp;lt;math&amp;gt;x \in S_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y \in S_3'&amp;lt;/math&amp;gt;&lt;br /&gt;
## &amp;lt;math&amp;gt;x \in S_1'&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y \in S_3'&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Obviously, this case distinction covers all potential cases, so the claim is proved.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
=== Statement: ===&lt;br /&gt;
[[File:Quicksortrecursion.png|350px|thumb|right|recursion depth of quick sort : [A] best case, [B] avg. case, [C] worst case]]&lt;br /&gt;
In the worst case, the complexity is &amp;lt;math&amp;gt;\Theta(n^2)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the pivot rule ensures for some &amp;lt;math&amp;gt;\alpha &amp;lt; 1&amp;lt;/math&amp;gt; that the lengths of &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_3&amp;lt;/math&amp;gt; are at most &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; times the size of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, then it is even &amp;lt;math&amp;gt;O(n \log n)&amp;lt;/math&amp;gt; in the worst case.&lt;br /&gt;
&lt;br /&gt;
If each pivot value is chosen uniformly randomly from members of the respective sequence and if all selections of pivot values are stochastically independent, the average-case complexity is &amp;lt;math&amp;gt;O(n \log n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Proof: ===&lt;br /&gt;
First note that the complexity for a single recursive call on &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; (disregarding the complexity for the recursive descents on &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_3&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;O(|S|)&amp;lt;/math&amp;gt;. On each recursive level, all calls are on distinct subsets of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;. Therefore, the number of recursive calls with non-empty sequences on one recursive level is in &amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt;. The number of calls with empty sequences on one level is at most twice the total number of calls with non-empty sequences on the previous level. Hence, the number of calls with empty sequences on one recursive level is in &amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt; as well. In summary, the total complexity on a recursive level is &amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt;. So, for the total complexity, it remains to estimate the number of recursive levels.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now consider the first statement. The recursion variant implies that the deepest recursive level is &amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt;. This gives the claimed &amp;lt;math&amp;gt;O(n^2)&amp;lt;/math&amp;gt; in the worst case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next assume there is a fixed &amp;lt;math&amp;gt;\alpha &amp;lt; 1&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;|S_1| \leq \alpha \cdot|S|&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;|S_3| \leq \alpha \cdot|S|&amp;lt;/math&amp;gt; is guaranteed in each recursive call. Then the length of any sequence on recursive level &amp;lt;math&amp;gt;\#i&amp;lt;/math&amp;gt; is at most &amp;lt;math&amp;gt;\alpha ^ i \cdot |S|&amp;lt;/math&amp;gt;. Therefore, the maximal recursive depth is &amp;lt;math&amp;gt;\lceil \log_{a-1}(n)\rceil&amp;lt;/math&amp;gt;. Since &amp;lt;math&amp;gt;\alpha^{-1} &amp;gt; 1&amp;lt;/math&amp;gt;, the total complexity is in &amp;lt;math&amp;gt;O(n \log n)&amp;lt;/math&amp;gt; in the worst case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the last statement, the average-case analysis, first note that the number of comparisons alone has the same asymptotic complexity as the algorithm as a whole. Next note that any &amp;lt;math&amp;gt;x,y \in S&amp;lt;/math&amp;gt; are compared at most once throughout the entire algorithm if, and only if, &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; is chosen as the pivot value for a subsequence to which both elements belong. For &amp;lt;math&amp;gt;x,y \in S&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;Pr(x,y)&amp;lt;/math&amp;gt; denote the probability that &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; are indeed compared. Since comparison events are distinct and &amp;lt;math&amp;gt;Pr(x,y )\in \{0,1\}&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;x,y \in S&amp;lt;/math&amp;gt;, the [[Expected value|expected number]] of comparisons is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\sum_{x,y \in S, x \neq y} Pr(x,y)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;n := |S|&amp;lt;/math&amp;gt;, and for &amp;lt;math&amp;gt;i,j \in \{1,\dots,n\}&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;Pr(i,j)&amp;lt;/math&amp;gt; denote the probability that the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-th and the &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;-th elemet of the eventual sorted sequence are compared throughout the algorithm. Using this notation, we may rewrite the above summation as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\sum_{x,y \in S, x \neq y} Pr(x,y) = \sum_{i=1}^{n-1} \sum_{j = i+1}^{n} Pr(i,j)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;math&amp;gt;i,j \in \{1,\dots,n\}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;i &amp;lt; j&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt; S_{ij}&amp;lt;/math&amp;gt; denote the subsequence of the eventual sorted sequence that starts with &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; and ends with &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;. The elements &amp;lt;math&amp;gt;\#i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\#j&amp;lt;/math&amp;gt; are compared if, and only if, &amp;lt;math&amp;gt;\#i&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\#j&amp;lt;/math&amp;gt; is the very first element of &amp;lt;math&amp;gt;S_{ij}&amp;lt;/math&amp;gt; to be chosen as a pivot. The probability of this event is &amp;lt;math&amp;gt;\frac{2}{|S_{ij}|} = \frac{2}{j - i + 1}&amp;lt;/math&amp;gt;, so we obtain&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\sum_{i=1}^{n-1} \sum_{j = i+1}^{n} \frac{2}{j-i+1}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Substituting &amp;lt;math&amp;gt;k := j-i&amp;lt;/math&amp;gt;, this gives&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\sum_{i=1}^{n-1} \sum_{j = i+1}^{n} \frac{2}{j-i+1} = \sum_{i=1}^{n-1} \sum_{k=1}^{n} \frac{2}{k+1} \leq 2(n - 1)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\sum_{k=1}^n \frac{1}{k+1} \leq 2(n-1)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\sum_{k+1}^n \frac{1}{k}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#Rate_of_divergence asymptotic behavior] of the [http://en.wikipedia.org/wiki/Harmonic_series_(mathematics) harmonic series] is &amp;lt;math&amp;gt;\Theta(\log n)&amp;lt;/math&amp;gt;, so the last expression is &amp;lt;math&amp;gt;\Theta(n \log n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Further information ==&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is an array, &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; cannot be decomposed into subsequences. We would liko to avoid the need for additional arrays and copy operations. Instead, the array should be sorted in-place, that is, by swap operations on pairs of elements. The auxiliary procedure, [[Pivot partitioning by scanning]], is designed exactly for that: it permutes the array such that each of &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S_2&amp;lt;/math&amp;gt; is a subarray. Then each recursive call of Quicksort operates on a subarray of the input array, which is specified by two index pointers.&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Quicksortrecursion.png&amp;diff=1867</id>
		<title>File:Quicksortrecursion.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Quicksortrecursion.png&amp;diff=1867"/>
		<updated>2014-11-09T15:28:42Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1864</id>
		<title>Sorting Algorithms</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1864"/>
		<updated>2014-11-09T14:18:14Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.&lt;br /&gt;
&lt;br /&gt;
Instead of numbers you can sort any data, e.g. string. There must be a relation between the elements of the set, so to say, an ordering relation &amp;lt;math&amp;gt; \leq &amp;lt;/math&amp;gt; has to be defined.&lt;br /&gt;
&lt;br /&gt;
Often, the data is a set of complex data types, that has to be sorted by a special criteria. For example you have a set of person descriptions to be sorted by the birth dates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n \in \N&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = a_0, \dots, a_{n-1}&amp;lt;/math&amp;gt; a finit sequence with &amp;lt;math&amp;gt;a_i \in \N \quad (i = 0, \dots, n-1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''sorting problem'' is to find a sequence &amp;lt;math&amp;gt;a_{\varphi (0)}, \dots, a_{\varphi (n-1)}&amp;lt;/math&amp;gt; with folloing constraints:&lt;br /&gt;
:* &amp;lt;math&amp;gt;a_{\varphi(i)} \leq a_{\varphi(j)} \quad \forall i,j \in \{0, \dots, n-1\}, i &amp;lt; j&amp;lt;/math&amp;gt;&lt;br /&gt;
:* the mapping &amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a permutation of the index set &amp;lt;math&amp;gt;\{0, \dots, n-1\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n = 8&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = 3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
:{|&lt;br /&gt;
|style=&amp;quot;width: 4em&amp;quot;| &amp;lt;math&amp;gt;i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;\varphi(i):&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;2 \ 6 \ 5 \ 0 \ 4 \ 3 \ 7 \ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_{\varphi(i)}:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;1 \ 2 \ 3 \ 3 \ 3 \ 4 \ 6 \ 8&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Important algorithms ==&lt;br /&gt;
* [[Bogosort]]&lt;br /&gt;
* [[Bubble]]&lt;br /&gt;
* [[Bubblesort]]&lt;br /&gt;
* [[Bucketsort]]&lt;br /&gt;
* [[Insertion sort]]&lt;br /&gt;
* [[Mergesort]]&lt;br /&gt;
* [[Quicksort]]&lt;br /&gt;
* [[Selection sort]]&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1854</id>
		<title>Sorting Algorithms</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1854"/>
		<updated>2014-11-09T11:45:54Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.&lt;br /&gt;
&lt;br /&gt;
Instead of numbers you can sort any data, e.g. string. There must be a relation between the elements of the set, so to say, an ordering relation &amp;lt;math&amp;gt; \leq &amp;lt;/math&amp;gt; has to be defined.&lt;br /&gt;
&lt;br /&gt;
Often, the data is a set of complex data types, that has to be sorted by a special criteria. For example you have a set of person descriptions to be sorted by the birth dates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n \in \N&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = a_0, \dots, a_{n-1}&amp;lt;/math&amp;gt; a finit sequence with &amp;lt;math&amp;gt;a_i \in \N \quad (i = 0, \dots, n-1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''sorting problem'' is to find a sequence &amp;lt;math&amp;gt;a_{\varphi (0)}, \dots, a_{\varphi (n-1)}&amp;lt;/math&amp;gt; with folloing constraints:&lt;br /&gt;
:* &amp;lt;math&amp;gt;a_{\varphi(i)} \leq a_{\varphi(j)} \quad \forall i,j \in \{0, \dots, n-1\}, i &amp;lt; j&amp;lt;/math&amp;gt;&lt;br /&gt;
:* the mapping &amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a permutation of the index set &amp;lt;math&amp;gt;\{0, \dots, n-1\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n = 8&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = 3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
:{|&lt;br /&gt;
|style=&amp;quot;width: 4em&amp;quot;| &amp;lt;math&amp;gt;i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;\varphi(i):&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;2 \ 6 \ 5 \ 0 \ 4 \ 3 \ 7 \ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_{\varphi(i)}:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;1 \ 2 \ 3 \ 3 \ 3 \ 4 \ 6 \ 8&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1853</id>
		<title>Sorting Algorithms</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1853"/>
		<updated>2014-11-09T11:39:21Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.&lt;br /&gt;
&lt;br /&gt;
Instead of numbers you can sort any data, e.g. string. There must be a relation between the elements of the set, so to say, an ordering relation &amp;lt;math&amp;gt; \leq &amp;lt;/math&amp;gt; has to be defined.&lt;br /&gt;
&lt;br /&gt;
Often, the data is a set of complex data types, that has to be sorted by a special criteria. For example you have a set of person descriptions to be sorted by the birth dates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n \in \N&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = a_0, \dots, a_{n-1}&amp;lt;/math&amp;gt; a finit sequence with &amp;lt;math&amp;gt;a_i \in \N \quad (i = 0, \dots, n-1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''sorting problem'' is to find a sequence &amp;lt;math&amp;gt;a_{\varphi (0)}, \dots, a_{\varphi (n-1)}&amp;lt;/math&amp;gt; with folloing constraints:&lt;br /&gt;
:* &amp;lt;math&amp;gt;a_{\varphi(i)} \leq a_{\varphi(j)} \quad \forall i,j \in \{0, \dots, n-1\}, i &amp;lt; j&amp;lt;/math&amp;gt;&lt;br /&gt;
:* the mapping &amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a permutation of the index set &amp;lt;math&amp;gt;\{0, \dots, n-1\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n = 8&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = 3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
:{|&lt;br /&gt;
| &amp;lt;math&amp;gt;i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_i:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;\varphi(i):&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;2 \ 6 \ 5 \ 0 \ 4 \ 3 \ 7 \ 1&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_{\varphi(i)}:&amp;lt;/math&amp;gt; || &amp;lt;math&amp;gt;1 \ 2 \ 3 \ 3 \ 3 \ 4 \ 6 \ 8&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1852</id>
		<title>Sorting Algorithms</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1852"/>
		<updated>2014-11-09T11:34:22Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.&lt;br /&gt;
&lt;br /&gt;
Instead of numbers you can sort any data, e.g. string. There must be a relation between the elements of the set, so to say, an ordering relation &amp;lt;math&amp;gt; \leq &amp;lt;/math&amp;gt; has to be defined.&lt;br /&gt;
&lt;br /&gt;
Often, the data is a set of complex data types, that has to be sorted by a special criteria. For example you have a set of person descriptions to be sorted by the birth dates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Definition ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n \in \N&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = a_0, \dots, a_{n-1}&amp;lt;/math&amp;gt; a finit sequence with &amp;lt;math&amp;gt;a_i \in \N \quad (i = 0, \dots, n-1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''sorting problem'' is to find a sequence &amp;lt;math&amp;gt;a_{\varphi (0)}, \dots, a_{\varphi (n-1)}&amp;lt;/math&amp;gt; with folloing constraints:&lt;br /&gt;
:* &amp;lt;math&amp;gt;a_{\varphi(i)} \leq a_{\varphi(j)} \quad \forall i,j \in \{0, \dots, n-1\}, i &amp;lt; j&amp;lt;/math&amp;gt;&lt;br /&gt;
:* the mapping &amp;lt;math&amp;gt;\varphi&amp;lt;/math&amp;gt; is a permutation of the index set &amp;lt;math&amp;gt;\{0, \dots, n-1\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Let &amp;lt;math&amp;gt;n = 8&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;a = 3 \ 8 \ 1 \ 4 \ 3 \ 3 \ 2 \ 6&amp;lt;/math&amp;gt;&lt;br /&gt;
{|&lt;br /&gt;
| &amp;lt;math&amp;gt;i:&amp;lt;/math&amp;gt;&lt;br /&gt;
| &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_i:&amp;lt;/math&amp;gt;&lt;br /&gt;
| &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;\varphi(i):&amp;lt;/math&amp;gt;&lt;br /&gt;
| &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;a_{\varphi(i)}:&amp;lt;/math&amp;gt;\quad&lt;br /&gt;
| &amp;lt;math&amp;gt;0 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1848</id>
		<title>Sorting Algorithms</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Sorting_Algorithms&amp;diff=1848"/>
		<updated>2014-11-09T10:53:19Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: Created page with &amp;quot;== General information ==  The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.  I...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== General information ==&lt;br /&gt;
&lt;br /&gt;
The sorting problem is one of the most frequent algorthmic problems. Its simplest form is to sort a finit set of numbers ascending or descending.&lt;br /&gt;
&lt;br /&gt;
Instead of numbers you can sort any data, e.g. string. There must be a relation between the elements of the set, so to say, an ordering relation &amp;lt;math&amp;gt; \leq &amp;lt;/math&amp;gt; has to be defined.&lt;br /&gt;
&lt;br /&gt;
Often, the data is a set of complex data types, that has to be sorted by a special criteria. For example you have a set of person descriptions to be sorted by the birth dates.&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Strongly_connected_components&amp;diff=1525</id>
		<title>Strongly connected components</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Strongly_connected_components&amp;diff=1525"/>
		<updated>2014-10-23T15:55:53Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
[[File:Scc.png|300px|thumb|right|Graph with marked strongly connected components]]&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; be a [[Basic graph definitions|directed graph]]. Consider the following equivalence relation on the nodes: &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; are equivalent if, and only 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; and a path from &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. The equivalence classes are called the '''strongly connected components (SCC)''' of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A [[Basic graph definitions|directed graph]] &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A set of sets of nodes. Each set of nodes contains exactly the nodes of one SCC. The correspndence between SCC and sets of nodes is one-to-one.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
====STRONGLY-CONNECTED-COMPONENTS(''D'')====&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;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
# [[Kosaraju]]&lt;br /&gt;
&lt;br /&gt;
== Further information ==&lt;br /&gt;
''STRONGLY-CONNECTED-COMPONENTS'' runs in linear time.&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Strongly_connected_components&amp;diff=1524</id>
		<title>Strongly connected components</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Strongly_connected_components&amp;diff=1524"/>
		<updated>2014-10-23T15:54:01Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
[[File:Scc.png|300px|thumb|right|Graph with marked strongly connected components]]&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; be a [[Basic graph definitions|directed graph]]. Consider the following equivalence relation on the nodes: &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; are equivalent if, and only 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; and a path from &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. The equivalence classes are called the '''strongly connected components (SCC)''' of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A [[Basic graph definitions|directed graph]] &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A set of sets of nodes. Each set of nodes contains exactly the nodes of one SCC. The correspndence between SCC and sets of nodes is one-to-one.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
====STRONGLY-CONNECTED-COMPONENTS(''D'')====&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;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
# [[Kosaraju]]&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Strongly_connected_components&amp;diff=1523</id>
		<title>Strongly connected components</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Strongly_connected_components&amp;diff=1523"/>
		<updated>2014-10-23T15:51:38Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Definition ==&lt;br /&gt;
[[File:Scc.png|300px|thumb|right|Graph with marked strongly connected components]]&lt;br /&gt;
Let &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt; be a [[Basic graph definitions|directed graph]]. Consider the following equivalence relation on the nodes: &amp;lt;math&amp;gt;v\in V&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w\in V&amp;lt;/math&amp;gt; are equivalent if, and only if, there is a path fmo &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; and a path from &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;. The equivalence classes are called the '''strongly connected components (SCC)''' of &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
A [[Basic graph definitions|directed graph]] &amp;lt;math&amp;gt;G=(V,A)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
A set of sets of nodes. Each set of nodes contains exactly the nodes of one SCC. The correspndence between SCC and sets of nodes is one-to-one.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
====STRONGLY-CONNECTED-COMPONENTS(''D'')====&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;br /&gt;
&lt;br /&gt;
== Known algorithms ==&lt;br /&gt;
&lt;br /&gt;
# [[Kosaraju]]&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dijkstra&amp;diff=1481</id>
		<title>Dijkstra</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dijkstra&amp;diff=1481"/>
		<updated>2014-10-22T13:04:53Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Further information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
[[Category:All Pairs Shortest Paths]]&lt;br /&gt;
&amp;lt;div class=&amp;quot;plainlinks&amp;quot; style=&amp;quot;float:right;margin:0 0 5px 5px; border:1px solid #AAAAAA; width:auto; padding:1em; margin: 0px 0px 1em 1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.8em;font-weight:bold;text-align: center;margin:0.2em 0 1em 0&amp;quot;&amp;gt;Dijkstra&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 1em 0; text-align:center&amp;quot;&amp;gt;whatever&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 .5em 0;text-align:center&amp;quot;&amp;gt;[[File:olw_logo1.png|20px]][https://openlearnware.tu-darmstadt.de/#!/resource/dijkstra-2310 Openlearnware]&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Dijstra's algorithm''' is a graph algortihm solving the single-source shortest-paths problem.&lt;br /&gt;
&lt;br /&gt;
== Requirements == &lt;br /&gt;
&lt;br /&gt;
* directed Graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt;&lt;br /&gt;
* weight function &amp;lt;math&amp;gt;w\colon E\to\mathbb R&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\forall(u,v)\in E\colon w(u,v)\geq 0&amp;lt;/math&amp;gt;&lt;br /&gt;
* source &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt;&lt;br /&gt;
* Datastruct &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; &lt;br /&gt;
* Datastruct &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Single source shortest paths]]&lt;br /&gt;
&lt;br /&gt;
'''Prerequisities:''' For all &amp;lt;math&amp;gt;\alpha \in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;l(a) \geq 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Type of algortihm:''' loop&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A temporary '''distance value''' &amp;lt;math&amp;gt;\delta(v) \in \R&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt;. At termination, it is &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\Delta(v)&amp;lt;/math&amp;gt; is the shortest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path.&lt;br /&gt;
# A [[bounded priority queue]] &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; of size &amp;lt;math&amp;gt;|V|-1&amp;lt;/math&amp;gt;, which contains nodes from &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; and takes their &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;-values as keys. The node with minimal key is returned.&lt;br /&gt;
&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' After &amp;lt;math&amp;gt;i \geq 0&amp;lt;/math&amp;gt; iterations:&lt;br /&gt;
# &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; contains all nodes of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; except &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; further nodes.&lt;br /&gt;
# For the nodes &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; not in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For the nodes &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt; is the length of a shortest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path that solely contains nodes not in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; (except for &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; itself, of course). As usual, this means &amp;lt;math&amp;gt;\delta(v) = +\infty&amp;lt;/math&amp;gt; if there is no such path.&lt;br /&gt;
&lt;br /&gt;
In particular, it is &amp;lt;math&amp;gt;\delta(v) \geq \Delta(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;
&lt;br /&gt;
'''Variant:''' &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; increases by &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
* &amp;lt;math&amp;gt;Q = \empty&amp;lt;/math&amp;gt;, which means that all nodes are reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and have been processed;&lt;br /&gt;
* otherwise, if &amp;lt;math&amp;gt;\delta(v) = +\infty&amp;lt;/math&amp;gt; for the next node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which means that &amp;lt;math&amp;gt;\delta(v) = + \infty&amp;lt;/math&amp;gt; for '''every''' node in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; and hence none of the nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
=== Abstract view: ===&lt;br /&gt;
# All nodes of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; except &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; have to be members of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Root &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; must have correct distance &amp;lt;math&amp;gt;\Delta(s) = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The other nodes must meet Invariant #3.&lt;br /&gt;
&lt;br /&gt;
=== Implementation: ===&lt;br /&gt;
# &amp;lt;math&amp;gt;\delta(s) := 0&amp;lt;/math&amp;gt;;&lt;br /&gt;
# For all &amp;lt;math&amp;gt;a = (s,v) \in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;\delta(v) := l(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v \in V\setminus\{s\}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;(s,v) \notin A&amp;lt;/math&amp;gt; set &amp;lt;math&amp;gt;\delta(v) := +\infty&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Insert all nodes in &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&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;
One node is extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, and the distance values of the endnodes of its outgoing arcs are updated to meet Invariant #3.&lt;br /&gt;
&lt;br /&gt;
=== Implementation: ===&lt;br /&gt;
# Extract the next node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each outgoing arc &amp;lt;math&amp;gt;a = (v,w) \in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;w \in Q&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;\delta(w) := min\{\delta(w), \delta(v) + l(a)\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Correctness: ===&lt;br /&gt;
The first invariant is trivially maintained. So we will focus on the second and third invariants.&amp;lt;br&amp;gt;&lt;br /&gt;
Consider the moment immediately before the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-iteration. The core of the proof is to show that &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt; hold at that moment (and hence forever). For a contradiction, suppose there is an &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; whose length is strictly less than &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt;. The third invariant implies that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; has nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; beside &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; denote the first such node on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Then none of the nodes on the subpath 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;u&amp;lt;/math&amp;gt; belonged to &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; at that moment (except for &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; itself, of course). Due to the [[Paths|prefix property]], this subpath is a shortest &amp;lt;math&amp;gt;(s,u)&amp;lt;/math&amp;gt;-path, so Invariant #3 implies &amp;lt;math&amp;gt;\delta(u) = \Delta(u)&amp;lt;/math&amp;gt;. On the other hand, the specific choice of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; implies &amp;lt;math&amp;gt;\delta(u) \geq \delta(v)&amp;lt;/math&amp;gt;. In summary, the subpath 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;w&amp;lt;/math&amp;gt; is not shorter than &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt;. To obtain &amp;lt;math&amp;gt;l(p) &amp;lt; \delta(v)&amp;lt;/math&amp;gt;, 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;v&amp;lt;/math&amp;gt; must have negative total length, which contradicts the prerequisite &amp;lt;math&amp;gt;l \geq 0&amp;lt;/math&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
Now we know &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt;. Therefore, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; fulfills the statement of the second invariant after the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-th iteration. Of course, the second invariant is not violated by any other node either, and is thus maintained.&amp;lt;br&amp;gt;&lt;br /&gt;
For a node &amp;lt;math&amp;gt;w \in V&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;P_i (w)&amp;lt;/math&amp;gt; denote the set of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths such that no node (except for &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; itself) is in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; immediately after the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-th iteration. In particular, the statement of the third invariant means that &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; is the length of a shortest path in &amp;lt;math&amp;gt;P_i (w)&amp;lt;/math&amp;gt;. The induction hypothesis says that &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; is the minimum length of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths in &amp;lt;math&amp;gt;P_{i-1} (w)&amp;lt;/math&amp;gt;. The difference &amp;lt;math&amp;gt;P_i (w) \setminus P_{i-1} (w)&amp;lt;/math&amp;gt; consists of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths such that &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is the last arc and all nodes except for &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; belong to &amp;lt;math&amp;gt;V_{i-1}&amp;lt;/math&amp;gt;. Therefore, the second step of the iteration incorporates &amp;lt;math&amp;gt;P_i (w) \setminus P_{i-1} (w)&amp;lt;/math&amp;gt; in the computation of &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; appropriately to maintain Invaraint #3.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The worst-case complexity is in &amp;lt;math&amp;gt;O(m+T(n)\cdot n)&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;, and &amp;lt;math&amp;gt;T(n)&amp;lt;/math&amp;gt; is the worst-case complexity for extraction/inserting nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Each node is inserted in and extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; at most once, respectively, which gives &amp;lt;math&amp;gt;O(T(n) \cdot n)&amp;lt;/math&amp;gt; in total. Also, each arc &amp;lt;math&amp;gt;(v,w) \in A&amp;lt;/math&amp;gt; is touched at most once, namely&lt;br /&gt;
* in the initialization if &amp;lt;math&amp;gt;v = s&amp;lt;/math&amp;gt;,&lt;br /&gt;
* when &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DIJKSTRA(''G,w,s'')====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 DIJKSTRA(''G,w,s'')&lt;br /&gt;
 1 INITIALIZE-SINGLE-SOURCE(''G,s'') &lt;br /&gt;
 2      ''S'' = &amp;amp;empty;&lt;br /&gt;
 3      ''Q'' = ''G.V''&lt;br /&gt;
 4      '''while''' ''Q'' &amp;amp;ne; &amp;amp;empty;&lt;br /&gt;
 5            ''u'' = EXTRACT-MIN(''Q'')&lt;br /&gt;
 6            ''S'' = ''S'' &amp;amp;cup; {''u''} &lt;br /&gt;
 7            '''for''' each vertex ''v'' &amp;amp;isin; G.''Adj''[''u'']&lt;br /&gt;
 8                 RELAX(''u,v,w'')&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====RELAX(''u,v,w'')====&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 RELAX(''u,v,w'')&lt;br /&gt;
 1 '''if''' ''v.d'' &amp;gt; ''u.d'' + ''w''(''u,v'')&lt;br /&gt;
 2       ''v.d'' = ''u.d'' + ''w''(''u,v'')&lt;br /&gt;
 3       ''v.&amp;amp;pi;'' = ''u''&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
====INITIALIZE-SINGLE-SOURCE(''G,s'')====&lt;br /&gt;
 INITIALIZE-SINGLE-SOURCE(''G,s'') &lt;br /&gt;
 1 '''for''' each vertex ''v'' &amp;amp;isin; ''G.V''&lt;br /&gt;
 2         ''v.d'' = &amp;amp;infin;&lt;br /&gt;
 3         ''v.&amp;amp;pi;'' = NIL&lt;br /&gt;
 4 ''s.d'' = 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further information ==&lt;br /&gt;
# We do not need to insert all nodes except for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In fact, it suffices to initially insert the endnodes of the outgoing arcs of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and, during an iteration, to insert the nodes of the outgoing arcs of the node that is being extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In a sense, the nodes of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; then constitute the &amp;quot;frontierline&amp;quot; of the algorithm. We choose another variant on Dijkstra's algorithm mainly for simplicity of presentation.&lt;br /&gt;
# Clearly, Dijkstra's algorithm also solves the single-source single-target case. In this case, Dijkstra may safely terminate once has been extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In fact, the loop invariant implies &amp;lt;math&amp;gt;\delta(t) = \Delta(t)&amp;lt;/math&amp;gt; from then on. This variant on Dijkstra's algorithm is sometimes called the '''early termination variant'''.[[File:Dijkstrabidirectional.png|350px|thumb|right|advantage of a bidirectional search]]&lt;br /&gt;
# In the single-source single-target case, two searches may be applied simultaneously: one from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, the other one from &amp;lt;math&amp;gt;t&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;. This variant is called '''bidirectional search'''. It terminates once one node has been seen by both searches. Then either the concatenation of the paths to this node from both searches is a shortest &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path, or such a path may be found among the paths of the following kind: There is an arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has been seen in the forward search from the source and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; has been seen in the backward search from &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
# In a scenario where we perform a large number of searches on the same graph and arc lengths, we do not need to touch the whole graph in each search: &lt;br /&gt;
## We change the algorithm as suggested by the first point: only keep the &amp;quot;frontierline&amp;quot; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
## We also change the algorithm as suggested by the second point: terminate once &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is processed.&lt;br /&gt;
## To avoid touching all nodes for initializing the &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;-values, we maintain sort of a '''version counter''', or '''time stamp''', for each node, which holds the ID of the last search that met this node. Whenever a node is met in a search and the nodes version counter does not equal the ID of the current search, the distance value of this node is regarded as &amp;lt;math&amp;gt;+ \infty&amp;lt;/math&amp;gt; (no matter what its current value is).[[File:Dijkstragoaldirected.png|350px|thumb|right|the length of a non-goal-directed arc grows, the length of a neutral arc stays the same and the length of the goal-directed arc shriks]]&lt;br /&gt;
# The early termination variant may be modified as follows: for and [[Paths|admissible distance function]] &amp;lt;math&amp;gt;h:V \to \R&amp;lt;/math&amp;gt;, replace length &amp;lt;math&amp;gt;l&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;l_h&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;l_h(a) := l(a) + h(w) - h(v)&amp;lt;/math&amp;gt; for each &amp;lt;math&amp;gt;a = (v,w) \in A&amp;lt;/math&amp;gt;. This variant is usually called '''goal-directed search'''. The heuristic idea is that we (hopefully) reach &amp;lt;math&amp;gt; t&amp;lt;/math&amp;gt; earlier because the arcs that roughly point towards &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; are shortened, and the arcs the roughly point in a direction away from &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; are lengthened.&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dijkstra&amp;diff=1480</id>
		<title>Dijkstra</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dijkstra&amp;diff=1480"/>
		<updated>2014-10-22T13:04:34Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Further information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
[[Category:All Pairs Shortest Paths]]&lt;br /&gt;
&amp;lt;div class=&amp;quot;plainlinks&amp;quot; style=&amp;quot;float:right;margin:0 0 5px 5px; border:1px solid #AAAAAA; width:auto; padding:1em; margin: 0px 0px 1em 1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.8em;font-weight:bold;text-align: center;margin:0.2em 0 1em 0&amp;quot;&amp;gt;Dijkstra&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 1em 0; text-align:center&amp;quot;&amp;gt;whatever&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 .5em 0;text-align:center&amp;quot;&amp;gt;[[File:olw_logo1.png|20px]][https://openlearnware.tu-darmstadt.de/#!/resource/dijkstra-2310 Openlearnware]&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Dijstra's algorithm''' is a graph algortihm solving the single-source shortest-paths problem.&lt;br /&gt;
&lt;br /&gt;
== Requirements == &lt;br /&gt;
&lt;br /&gt;
* directed Graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt;&lt;br /&gt;
* weight function &amp;lt;math&amp;gt;w\colon E\to\mathbb R&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\forall(u,v)\in E\colon w(u,v)\geq 0&amp;lt;/math&amp;gt;&lt;br /&gt;
* source &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt;&lt;br /&gt;
* Datastruct &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; &lt;br /&gt;
* Datastruct &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Single source shortest paths]]&lt;br /&gt;
&lt;br /&gt;
'''Prerequisities:''' For all &amp;lt;math&amp;gt;\alpha \in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;l(a) \geq 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Type of algortihm:''' loop&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A temporary '''distance value''' &amp;lt;math&amp;gt;\delta(v) \in \R&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt;. At termination, it is &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\Delta(v)&amp;lt;/math&amp;gt; is the shortest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path.&lt;br /&gt;
# A [[bounded priority queue]] &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; of size &amp;lt;math&amp;gt;|V|-1&amp;lt;/math&amp;gt;, which contains nodes from &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; and takes their &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;-values as keys. The node with minimal key is returned.&lt;br /&gt;
&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' After &amp;lt;math&amp;gt;i \geq 0&amp;lt;/math&amp;gt; iterations:&lt;br /&gt;
# &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; contains all nodes of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; except &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; further nodes.&lt;br /&gt;
# For the nodes &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; not in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For the nodes &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt; is the length of a shortest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path that solely contains nodes not in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; (except for &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; itself, of course). As usual, this means &amp;lt;math&amp;gt;\delta(v) = +\infty&amp;lt;/math&amp;gt; if there is no such path.&lt;br /&gt;
&lt;br /&gt;
In particular, it is &amp;lt;math&amp;gt;\delta(v) \geq \Delta(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;
&lt;br /&gt;
'''Variant:''' &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; increases by &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
* &amp;lt;math&amp;gt;Q = \empty&amp;lt;/math&amp;gt;, which means that all nodes are reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and have been processed;&lt;br /&gt;
* otherwise, if &amp;lt;math&amp;gt;\delta(v) = +\infty&amp;lt;/math&amp;gt; for the next node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which means that &amp;lt;math&amp;gt;\delta(v) = + \infty&amp;lt;/math&amp;gt; for '''every''' node in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; and hence none of the nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
=== Abstract view: ===&lt;br /&gt;
# All nodes of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; except &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; have to be members of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Root &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; must have correct distance &amp;lt;math&amp;gt;\Delta(s) = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The other nodes must meet Invariant #3.&lt;br /&gt;
&lt;br /&gt;
=== Implementation: ===&lt;br /&gt;
# &amp;lt;math&amp;gt;\delta(s) := 0&amp;lt;/math&amp;gt;;&lt;br /&gt;
# For all &amp;lt;math&amp;gt;a = (s,v) \in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;\delta(v) := l(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v \in V\setminus\{s\}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;(s,v) \notin A&amp;lt;/math&amp;gt; set &amp;lt;math&amp;gt;\delta(v) := +\infty&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Insert all nodes in &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&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;
One node is extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, and the distance values of the endnodes of its outgoing arcs are updated to meet Invariant #3.&lt;br /&gt;
&lt;br /&gt;
=== Implementation: ===&lt;br /&gt;
# Extract the next node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each outgoing arc &amp;lt;math&amp;gt;a = (v,w) \in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;w \in Q&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;\delta(w) := min\{\delta(w), \delta(v) + l(a)\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Correctness: ===&lt;br /&gt;
The first invariant is trivially maintained. So we will focus on the second and third invariants.&amp;lt;br&amp;gt;&lt;br /&gt;
Consider the moment immediately before the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-iteration. The core of the proof is to show that &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt; hold at that moment (and hence forever). For a contradiction, suppose there is an &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; whose length is strictly less than &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt;. The third invariant implies that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; has nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; beside &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; denote the first such node on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Then none of the nodes on the subpath 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;u&amp;lt;/math&amp;gt; belonged to &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; at that moment (except for &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; itself, of course). Due to the [[Paths|prefix property]], this subpath is a shortest &amp;lt;math&amp;gt;(s,u)&amp;lt;/math&amp;gt;-path, so Invariant #3 implies &amp;lt;math&amp;gt;\delta(u) = \Delta(u)&amp;lt;/math&amp;gt;. On the other hand, the specific choice of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; implies &amp;lt;math&amp;gt;\delta(u) \geq \delta(v)&amp;lt;/math&amp;gt;. In summary, the subpath 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;w&amp;lt;/math&amp;gt; is not shorter than &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt;. To obtain &amp;lt;math&amp;gt;l(p) &amp;lt; \delta(v)&amp;lt;/math&amp;gt;, 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;v&amp;lt;/math&amp;gt; must have negative total length, which contradicts the prerequisite &amp;lt;math&amp;gt;l \geq 0&amp;lt;/math&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
Now we know &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt;. Therefore, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; fulfills the statement of the second invariant after the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-th iteration. Of course, the second invariant is not violated by any other node either, and is thus maintained.&amp;lt;br&amp;gt;&lt;br /&gt;
For a node &amp;lt;math&amp;gt;w \in V&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;P_i (w)&amp;lt;/math&amp;gt; denote the set of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths such that no node (except for &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; itself) is in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; immediately after the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-th iteration. In particular, the statement of the third invariant means that &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; is the length of a shortest path in &amp;lt;math&amp;gt;P_i (w)&amp;lt;/math&amp;gt;. The induction hypothesis says that &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; is the minimum length of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths in &amp;lt;math&amp;gt;P_{i-1} (w)&amp;lt;/math&amp;gt;. The difference &amp;lt;math&amp;gt;P_i (w) \setminus P_{i-1} (w)&amp;lt;/math&amp;gt; consists of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths such that &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is the last arc and all nodes except for &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; belong to &amp;lt;math&amp;gt;V_{i-1}&amp;lt;/math&amp;gt;. Therefore, the second step of the iteration incorporates &amp;lt;math&amp;gt;P_i (w) \setminus P_{i-1} (w)&amp;lt;/math&amp;gt; in the computation of &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; appropriately to maintain Invaraint #3.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The worst-case complexity is in &amp;lt;math&amp;gt;O(m+T(n)\cdot n)&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;, and &amp;lt;math&amp;gt;T(n)&amp;lt;/math&amp;gt; is the worst-case complexity for extraction/inserting nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Each node is inserted in and extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; at most once, respectively, which gives &amp;lt;math&amp;gt;O(T(n) \cdot n)&amp;lt;/math&amp;gt; in total. Also, each arc &amp;lt;math&amp;gt;(v,w) \in A&amp;lt;/math&amp;gt; is touched at most once, namely&lt;br /&gt;
* in the initialization if &amp;lt;math&amp;gt;v = s&amp;lt;/math&amp;gt;,&lt;br /&gt;
* when &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DIJKSTRA(''G,w,s'')====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 DIJKSTRA(''G,w,s'')&lt;br /&gt;
 1 INITIALIZE-SINGLE-SOURCE(''G,s'') &lt;br /&gt;
 2      ''S'' = &amp;amp;empty;&lt;br /&gt;
 3      ''Q'' = ''G.V''&lt;br /&gt;
 4      '''while''' ''Q'' &amp;amp;ne; &amp;amp;empty;&lt;br /&gt;
 5            ''u'' = EXTRACT-MIN(''Q'')&lt;br /&gt;
 6            ''S'' = ''S'' &amp;amp;cup; {''u''} &lt;br /&gt;
 7            '''for''' each vertex ''v'' &amp;amp;isin; G.''Adj''[''u'']&lt;br /&gt;
 8                 RELAX(''u,v,w'')&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====RELAX(''u,v,w'')====&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 RELAX(''u,v,w'')&lt;br /&gt;
 1 '''if''' ''v.d'' &amp;gt; ''u.d'' + ''w''(''u,v'')&lt;br /&gt;
 2       ''v.d'' = ''u.d'' + ''w''(''u,v'')&lt;br /&gt;
 3       ''v.&amp;amp;pi;'' = ''u''&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
====INITIALIZE-SINGLE-SOURCE(''G,s'')====&lt;br /&gt;
 INITIALIZE-SINGLE-SOURCE(''G,s'') &lt;br /&gt;
 1 '''for''' each vertex ''v'' &amp;amp;isin; ''G.V''&lt;br /&gt;
 2         ''v.d'' = &amp;amp;infin;&lt;br /&gt;
 3         ''v.&amp;amp;pi;'' = NIL&lt;br /&gt;
 4 ''s.d'' = 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further information ==&lt;br /&gt;
# We do not need to insert all nodes except for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In fact, it suffices to initially insert the endnodes of the outgoing arcs of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and, during an iteration, to insert the nodes of the outgoing arcs of the node that is being extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In a sense, the nodes of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; then constitute the &amp;quot;frontierline&amp;quot; of the algorithm. We choose another variant on Dijkstra's algorithm mainly for simplicity of presentation.&lt;br /&gt;
# Clearly, Dijkstra's algorithm also solves the single-source single-target case. In this case, Dijkstra may safely terminate once has been extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In fact, the loop invariant implies &amp;lt;math&amp;gt;\delta(t) = \Delta(t)&amp;lt;/math&amp;gt; from then on. This variant on Dijkstra's algorithm is sometimes called the '''early termination variant'''.[[File:Dijkstrabidirectional.png|350px|thumb|right|advantage of a bidirectional search]]&lt;br /&gt;
# In the single-source single-target case, two searches may be applied simultaneously: one from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, the other one from &amp;lt;math&amp;gt;t&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;. This variant is called '''bidirectional search'''. It terminates once one node has been seen by both searches. Then either the concatenation of the paths to this node from both searches is a shortest &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path, or such a path may be found among the paths of the following kind: There is an arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has been seen in the forward search from the source and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; has been seen in the backward search from &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
# In a scenario where we perform a large number of searches on the same graph and arc lengths, we do not need to touch the whole graph in each search: &lt;br /&gt;
## We change the algorithm as suggested by the first point: only keep the &amp;quot;frontierline&amp;quot; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
## We also change the algorithm as suggested by the second point: terminate once &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is processed.&lt;br /&gt;
## To avoid touching all nodes for initializing the &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;-values, we maintain sort of a '''version counter''', or '''time stamp''', for each node, which holds the ID of the last search that met this node. Whenever a node is met in a search and the nodes version counter does not equal the ID of the current search, the distance value of this node is regarded as &amp;lt;math&amp;gt;+ \infty&amp;lt;/math&amp;gt; (no matter what its current value is).&lt;br /&gt;
[[File:Dijkstragoaldirected.png|350px|thumb|right|the length of a non-goal-directed arc grows, the length of a neutral arc stays the same and the length of the goal-directed arc shriks]]&lt;br /&gt;
# The early termination variant may be modified as follows: for and [[Paths|admissible distance function]] &amp;lt;math&amp;gt;h:V \to \R&amp;lt;/math&amp;gt;, replace length &amp;lt;math&amp;gt;l&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;l_h&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;l_h(a) := l(a) + h(w) - h(v)&amp;lt;/math&amp;gt; for each &amp;lt;math&amp;gt;a = (v,w) \in A&amp;lt;/math&amp;gt;. This variant is usually called '''goal-directed search'''. The heuristic idea is that we (hopefully) reach &amp;lt;math&amp;gt; t&amp;lt;/math&amp;gt; earlier because the arcs that roughly point towards &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; are shortened, and the arcs the roughly point in a direction away from &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; are lengthened.&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstragoaldirected.png&amp;diff=1478</id>
		<title>File:Dijkstragoaldirected.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstragoaldirected.png&amp;diff=1478"/>
		<updated>2014-10-22T12:59:23Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: examples for new length in a goal-directed search&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;examples for new length in a goal-directed search&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dijkstra&amp;diff=1474</id>
		<title>Dijkstra</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=Dijkstra&amp;diff=1474"/>
		<updated>2014-10-22T11:48:00Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: /* Further information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Graph Algorithms]]&lt;br /&gt;
[[Category:All Pairs Shortest Paths]]&lt;br /&gt;
&amp;lt;div class=&amp;quot;plainlinks&amp;quot; style=&amp;quot;float:right;margin:0 0 5px 5px; border:1px solid #AAAAAA; width:auto; padding:1em; margin: 0px 0px 1em 1em;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.8em;font-weight:bold;text-align: center;margin:0.2em 0 1em 0&amp;quot;&amp;gt;Dijkstra&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 1em 0; text-align:center&amp;quot;&amp;gt;whatever&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;font-size: 1.2em; margin:.5em 0 .5em 0;text-align:center&amp;quot;&amp;gt;[[File:olw_logo1.png|20px]][https://openlearnware.tu-darmstadt.de/#!/resource/dijkstra-2310 Openlearnware]&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Dijstra's algorithm''' is a graph algortihm solving the single-source shortest-paths problem.&lt;br /&gt;
&lt;br /&gt;
== Requirements == &lt;br /&gt;
&lt;br /&gt;
* directed Graph &amp;lt;math&amp;gt;G=(V,E)&amp;lt;/math&amp;gt;&lt;br /&gt;
* weight function &amp;lt;math&amp;gt;w\colon E\to\mathbb R&amp;lt;/math&amp;gt;&lt;br /&gt;
* &amp;lt;math&amp;gt;\forall(u,v)\in E\colon w(u,v)\geq 0&amp;lt;/math&amp;gt;&lt;br /&gt;
* source &amp;lt;math&amp;gt;s\in V&amp;lt;/math&amp;gt;&lt;br /&gt;
* Datastruct &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; &lt;br /&gt;
* Datastruct &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
'''Algorithmic problem:''' [[Single source shortest paths]]&lt;br /&gt;
&lt;br /&gt;
'''Prerequisities:''' For all &amp;lt;math&amp;gt;\alpha \in A&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;l(a) \geq 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Type of algortihm:''' loop&lt;br /&gt;
&lt;br /&gt;
'''Auxiliary data:'''&lt;br /&gt;
# A temporary '''distance value''' &amp;lt;math&amp;gt;\delta(v) \in \R&amp;lt;/math&amp;gt; for each node &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt;. At termination, it is &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\Delta(v)&amp;lt;/math&amp;gt; is the shortest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path.&lt;br /&gt;
# A [[bounded priority queue]] &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; of size &amp;lt;math&amp;gt;|V|-1&amp;lt;/math&amp;gt;, which contains nodes from &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; and takes their &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;-values as keys. The node with minimal key is returned.&lt;br /&gt;
&lt;br /&gt;
== Abstract view ==&lt;br /&gt;
&lt;br /&gt;
'''Invariant:''' After &amp;lt;math&amp;gt;i \geq 0&amp;lt;/math&amp;gt; iterations:&lt;br /&gt;
# &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; contains all nodes of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; except &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; further nodes.&lt;br /&gt;
# For the nodes &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; not in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, it is &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For the nodes &amp;lt;math&amp;gt;v \in V&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt; is the length of a shortest &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path that solely contains nodes not in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; (except for &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; itself, of course). As usual, this means &amp;lt;math&amp;gt;\delta(v) = +\infty&amp;lt;/math&amp;gt; if there is no such path.&lt;br /&gt;
&lt;br /&gt;
In particular, it is &amp;lt;math&amp;gt;\delta(v) \geq \Delta(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;
&lt;br /&gt;
'''Variant:''' &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; increases by &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Break condition:'''&lt;br /&gt;
* &amp;lt;math&amp;gt;Q = \empty&amp;lt;/math&amp;gt;, which means that all nodes are reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and have been processed;&lt;br /&gt;
* otherwise, if &amp;lt;math&amp;gt;\delta(v) = +\infty&amp;lt;/math&amp;gt; for the next node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which means that &amp;lt;math&amp;gt;\delta(v) = + \infty&amp;lt;/math&amp;gt; for '''every''' node in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; and hence none of the nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; is reachable from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Induction basis ==&lt;br /&gt;
=== Abstract view: ===&lt;br /&gt;
# All nodes of &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; except &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; have to be members of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Root &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; must have correct distance &amp;lt;math&amp;gt;\Delta(s) = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
# The other nodes must meet Invariant #3.&lt;br /&gt;
&lt;br /&gt;
=== Implementation: ===&lt;br /&gt;
# &amp;lt;math&amp;gt;\delta(s) := 0&amp;lt;/math&amp;gt;;&lt;br /&gt;
# For all &amp;lt;math&amp;gt;a = (s,v) \in A&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;\delta(v) := l(a)&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For all &amp;lt;math&amp;gt;v \in V\setminus\{s\}&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;(s,v) \notin A&amp;lt;/math&amp;gt; set &amp;lt;math&amp;gt;\delta(v) := +\infty&amp;lt;/math&amp;gt;.&lt;br /&gt;
# Insert all nodes in &amp;lt;math&amp;gt;V\setminus\{s\}&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&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;
One node is extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, and the distance values of the endnodes of its outgoing arcs are updated to meet Invariant #3.&lt;br /&gt;
&lt;br /&gt;
=== Implementation: ===&lt;br /&gt;
# Extract the next node &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
# For each outgoing arc &amp;lt;math&amp;gt;a = (v,w) \in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;w \in Q&amp;lt;/math&amp;gt;, set &amp;lt;math&amp;gt;\delta(w) := min\{\delta(w), \delta(v) + l(a)\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Correctness: ===&lt;br /&gt;
The first invariant is trivially maintained. So we will focus on the second and third invariants.&amp;lt;br&amp;gt;&lt;br /&gt;
Consider the moment immediately before the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-iteration. The core of the proof is to show that &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt; hold at that moment (and hence forever). For a contradiction, suppose there is an &amp;lt;math&amp;gt;(s,v)&amp;lt;/math&amp;gt;-path &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; whose length is strictly less than &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt;. The third invariant implies that &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt; has nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; beside &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; denote the first such node on &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. Then none of the nodes on the subpath 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;u&amp;lt;/math&amp;gt; belonged to &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; at that moment (except for &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; itself, of course). Due to the [[Paths|prefix property]], this subpath is a shortest &amp;lt;math&amp;gt;(s,u)&amp;lt;/math&amp;gt;-path, so Invariant #3 implies &amp;lt;math&amp;gt;\delta(u) = \Delta(u)&amp;lt;/math&amp;gt;. On the other hand, the specific choice of &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; implies &amp;lt;math&amp;gt;\delta(u) \geq \delta(v)&amp;lt;/math&amp;gt;. In summary, the subpath 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;w&amp;lt;/math&amp;gt; is not shorter than &amp;lt;math&amp;gt;\delta(v)&amp;lt;/math&amp;gt;. To obtain &amp;lt;math&amp;gt;l(p) &amp;lt; \delta(v)&amp;lt;/math&amp;gt;, 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;v&amp;lt;/math&amp;gt; must have negative total length, which contradicts the prerequisite &amp;lt;math&amp;gt;l \geq 0&amp;lt;/math&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
Now we know &amp;lt;math&amp;gt;\delta(v) = \Delta(v)&amp;lt;/math&amp;gt;. Therefore, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; fulfills the statement of the second invariant after the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-th iteration. Of course, the second invariant is not violated by any other node either, and is thus maintained.&amp;lt;br&amp;gt;&lt;br /&gt;
For a node &amp;lt;math&amp;gt;w \in V&amp;lt;/math&amp;gt; let &amp;lt;math&amp;gt;P_i (w)&amp;lt;/math&amp;gt; denote the set of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths such that no node (except for &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; itself) is in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; immediately after the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;-th iteration. In particular, the statement of the third invariant means that &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; is the length of a shortest path in &amp;lt;math&amp;gt;P_i (w)&amp;lt;/math&amp;gt;. The induction hypothesis says that &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; is the minimum length of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths in &amp;lt;math&amp;gt;P_{i-1} (w)&amp;lt;/math&amp;gt;. The difference &amp;lt;math&amp;gt;P_i (w) \setminus P_{i-1} (w)&amp;lt;/math&amp;gt; consists of all &amp;lt;math&amp;gt;(s,w)&amp;lt;/math&amp;gt;-paths such that &amp;lt;math&amp;gt;(v,w)&amp;lt;/math&amp;gt; is the last arc and all nodes except for &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; belong to &amp;lt;math&amp;gt;V_{i-1}&amp;lt;/math&amp;gt;. Therefore, the second step of the iteration incorporates &amp;lt;math&amp;gt;P_i (w) \setminus P_{i-1} (w)&amp;lt;/math&amp;gt; in the computation of &amp;lt;math&amp;gt;\delta(w)&amp;lt;/math&amp;gt; appropriately to maintain Invaraint #3.&lt;br /&gt;
&lt;br /&gt;
== Complexity ==&lt;br /&gt;
&lt;br /&gt;
'''Statement:''' The worst-case complexity is in &amp;lt;math&amp;gt;O(m+T(n)\cdot n)&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;, and &amp;lt;math&amp;gt;T(n)&amp;lt;/math&amp;gt; is the worst-case complexity for extraction/inserting nodes in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Proof:''' Each node is inserted in and extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; at most once, respectively, which gives &amp;lt;math&amp;gt;O(T(n) \cdot n)&amp;lt;/math&amp;gt; in total. Also, each arc &amp;lt;math&amp;gt;(v,w) \in A&amp;lt;/math&amp;gt; is touched at most once, namely&lt;br /&gt;
* in the initialization if &amp;lt;math&amp;gt;v = s&amp;lt;/math&amp;gt;,&lt;br /&gt;
* when &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; is extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
== Pseudocode == &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DIJKSTRA(''G,w,s'')====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 DIJKSTRA(''G,w,s'')&lt;br /&gt;
 1 INITIALIZE-SINGLE-SOURCE(''G,s'') &lt;br /&gt;
 2      ''S'' = &amp;amp;empty;&lt;br /&gt;
 3      ''Q'' = ''G.V''&lt;br /&gt;
 4      '''while''' ''Q'' &amp;amp;ne; &amp;amp;empty;&lt;br /&gt;
 5            ''u'' = EXTRACT-MIN(''Q'')&lt;br /&gt;
 6            ''S'' = ''S'' &amp;amp;cup; {''u''} &lt;br /&gt;
 7            '''for''' each vertex ''v'' &amp;amp;isin; G.''Adj''[''u'']&lt;br /&gt;
 8                 RELAX(''u,v,w'')&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====RELAX(''u,v,w'')====&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 RELAX(''u,v,w'')&lt;br /&gt;
 1 '''if''' ''v.d'' &amp;gt; ''u.d'' + ''w''(''u,v'')&lt;br /&gt;
 2       ''v.d'' = ''u.d'' + ''w''(''u,v'')&lt;br /&gt;
 3       ''v.&amp;amp;pi;'' = ''u''&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
====INITIALIZE-SINGLE-SOURCE(''G,s'')====&lt;br /&gt;
 INITIALIZE-SINGLE-SOURCE(''G,s'') &lt;br /&gt;
 1 '''for''' each vertex ''v'' &amp;amp;isin; ''G.V''&lt;br /&gt;
 2         ''v.d'' = &amp;amp;infin;&lt;br /&gt;
 3         ''v.&amp;amp;pi;'' = NIL&lt;br /&gt;
 4 ''s.d'' = 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further information ==&lt;br /&gt;
# We do not need to insert all nodes except for &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In fact, it suffices to initially insert the endnodes of the outgoing arcs of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and, during an iteration, to insert the nodes of the outgoing arcs of the node that is being extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In a sense, the nodes of &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; then constitute the &amp;quot;frontierline&amp;quot; of the algorithm. We choose another variant on Dijkstra's algorithm mainly for simplicity of presentation.&lt;br /&gt;
# Clearly, Dijkstra's algorithm also solves the single-source single-target case. In this case, Dijkstra may safely terminate once has been extracted from &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;. In fact, the loop invariant implies &amp;lt;math&amp;gt;\delta(t) = \Delta(t)&amp;lt;/math&amp;gt; from then on. This variant on Dijkstra's algorithm is sometimes called the '''early termination variant'''.[[File:Dijkstrabidirectional.png|350px|thumb|right|advantage of a bidirectional search]]&lt;br /&gt;
# In the single-source single-target case, two searches may be applied simultaneously: one from &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; on &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt;, the other one from &amp;lt;math&amp;gt;t&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;. This variant is called '''bidirectional search'''. It terminates once one node has been seen by both searches. Then either the concatenation of the paths to this node from both searches is a shortest &amp;lt;math&amp;gt;(s,t)&amp;lt;/math&amp;gt;-path, or such a path may be found among the paths of the following kind: There is an arc &amp;lt;math&amp;gt;(v,w)\in A&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt; has been seen in the forward search from the source and &amp;lt;math&amp;gt;w&amp;lt;/math&amp;gt; has been seen in the backward search from &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;.&lt;br /&gt;
# In a scenario where we perform a large number of searches on the same graph and arc lengths, we do not need to touch the whole graph in each search: &lt;br /&gt;
## We change the algorithm as suggested by the first point: only keep the &amp;quot;frontierline&amp;quot; in &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;.&lt;br /&gt;
## We also change the algorithm as suggested by the second point: terminate once &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is processed.&lt;br /&gt;
## To avoid touching all nodes for initializing the &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;-values, we maintain sort of a '''version counter''', or '''time stamp''', for each node, which holds the ID of the last search that met this node. Whenever a node is met in a search and the nodes version counter does not equal the ID of the current search, the distance value of this node is regarded as &amp;lt;math&amp;gt;+ \infty&amp;lt;/math&amp;gt; (no matter what its current value is).&lt;br /&gt;
# The early termination variant may be modified as follows: for and [[Paths|admissible distance function]] &amp;lt;math&amp;gt;h:V \to \R&amp;lt;/math&amp;gt;, replace length &amp;lt;math&amp;gt;l&amp;lt;/math&amp;gt; by &amp;lt;math&amp;gt;l_h&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;l_h(a) := l(a) + h(w) - h(v)&amp;lt;/math&amp;gt; for each &amp;lt;math&amp;gt;a = (v,w) \in A&amp;lt;/math&amp;gt;. This variant is usually called '''goal-directed search'''. The heuristic idea is that we (hopefully) reach &amp;lt;math&amp;gt; t&amp;lt;/math&amp;gt; earlier because the arcs that roughly point towards &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; are shortened, and the arcs the roughly point in a direction away from &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; are lengthened.&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1473</id>
		<title>File:Dijkstrabidirectional.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1473"/>
		<updated>2014-10-22T11:42:59Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: Mahn89 uploaded a new version of &amp;amp;quot;File:Dijkstrabidirectional.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;comparison of the areas used in a uni-directional case and a bi-directional one&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1472</id>
		<title>File:Dijkstrabidirectional.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1472"/>
		<updated>2014-10-22T11:42:35Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: Mahn89 uploaded a new version of &amp;amp;quot;File:Dijkstrabidirectional.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;comparison of the areas used in a uni-directional case and a bi-directional one&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1471</id>
		<title>File:Dijkstrabidirectional.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1471"/>
		<updated>2014-10-22T11:41:45Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: Mahn89 uploaded a new version of &amp;amp;quot;File:Dijkstrabidirectional.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;comparison of the areas used in a uni-directional case and a bi-directional one&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
	<entry>
		<id>https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1470</id>
		<title>File:Dijkstrabidirectional.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.algo.informatik.tu-darmstadt.de/index.php?title=File:Dijkstrabidirectional.png&amp;diff=1470"/>
		<updated>2014-10-22T11:17:17Z</updated>

		<summary type="html">&lt;p&gt;Mahn89: comparison of the areas used in a uni-directional case and a bi-directional one&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;comparison of the areas used in a uni-directional case and a bi-directional one&lt;/div&gt;</summary>
		<author><name>Mahn89</name></author>
	</entry>
</feed>