Dijkstra: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
==== dhg ==== | ==== dhg ==== | ||
== Pseudocode == | |||
<code> | |||
DIJKSTRA(G,w,s) | |||
INITIALIZE-SINGLE-SOURCE(G,s) | |||
S = ∅ | |||
Q = G.V | |||
while Q ∅ | |||
u = EXTRACT-MIN(Q) | |||
S = S {u} | |||
for each vertex v G.Adj[u] | |||
RELAX(u,v,w) | |||
</code> | |||
<syntaxhighlight lang="java" line> | |||
INSERTION-SORT(A) | |||
for j=2 to A.länge | |||
schlüssel=A[j] | |||
//füge A[j] in den sortierten Beginn des Arrays A[1..j-1] ein | |||
i=j-1 | |||
while i>0 und A[i]>schlüssel | |||
A[i+1]=A[i] | |||
i=i-1 | |||
A[i+1]=schlüssel | |||
</syntaxhighlight> |
Revision as of 17:26, 22 September 2014
Das is de Disjkstra
dhg
Pseudocode
DIJKSTRA(G,w,s)
INITIALIZE-SINGLE-SOURCE(G,s)
S = ∅
Q = G.V
while Q ∅
u = EXTRACT-MIN(Q)
S = S {u}
for each vertex v G.Adj[u]
RELAX(u,v,w)
INSERTION-SORT(A)
for j=2 to A.länge
schlüssel=A[j]
//füge A[j] in den sortierten Beginn des Arrays A[1..j-1] ein
i=j-1
while i>0 und A[i]>schlüssel
A[i+1]=A[i]
i=i-1
A[i+1]=schlüssel