Dijkstra's Algorithm
Dijkstra's Algorithm
Algorithm of
Dijkstra. Also called Dijkstra's Algorithm
shortest path algorithm
it is an algorithm for the
determination of the best path
short given a vertex origin to the
remaining vertices in
agraphwith weights in each
arista. Its name refers to
aEdsger Dijkstrawho lo
described for the first time
in1959.
Content
[hide]
1 Applications
2 Characteristics of Concept: The Dijkstra algorithm, also called
algorithm shortest path algorithm, it is a
3 Steps of the algorithm
algorithm for path determination
4 Algorithm execution
shortest path from a source vertex to the rest of
5 Final of the Process of
Execution vertices in a graph with weights on each
6 Pseudocode arista. Its name refers to Edsger
or6.1 Priority Queue Dijkstra, who described it for the first time
o6.2 Without a tail in 1959.
priority
7 External links
Applications
In multiple applications where graphs are applied, it is necessary to know the path of
minimum cost between two given vertices:
The shortest path problem from one vertex to another consists of determining the path from
lower cost, from a vertex u to another vertex v. The cost of a path is the sum of the
costs (pesos) of the arcs that compose it.
Characteristics of the algorithm
It is a greedy algorithm.
Work in stages, and take the best solution at each stage without considering
future consequences.
The optimum found in one stage can be modified later if a
better solution.
Execution of Algorithm
Step 1: Initialization
Step 2: Choose a vertex w∈ V - {A} such that D[w] is minimized, and add w to
solution set S
Step 3: each v∈ make D[v] ← min(D[v], D[w] + C[w, v])
Step 4: Choose a vertex w∈ V - {A, B} such that D[w] is minimal, and add w to
set solution S.
File:Algo09.JPG
Step 6: Choose a vertex w∈ V - {A, B, D} such that D[w] is minimum, and add w to it
solution set S.
Step 7: For each v∈ make D[v] ← min(D[v], D[w] + C[w, v])
Step 8: Choose a vertex w∈ V - {A, B, D, C} such that D[w] is minimal, and add
to the solution set S.
Final of the Execution Process
After step 8, we have the following situation:
So, since V-S=Ø, the algorithm ends, as for each node of the graph has...
determined what its minimum path is. As a result of the algorithm execution.
we have:
D[B] P[B]
10 50 30 60 A D A C
At the end of the execution of Dijkstra's algorithm, the array D stores the
costs of the minimum paths starting from the source vertex to the rest of the vertices. By
so, in our example, the minimum path from A to B has a cost of 10, the path
the minimum cost from A to C is 50, the minimum cost from A to D is 30 and the
the minimum path from A to E has a cost of 60.
Let's see how to obtain the shortest paths from the predecessor array.
The paths are reconstructed starting from the destination vertex until reaching the origin vertex.
MinimumPath (A, B) = AB since P[B]=A
MinimumPath (A, C) = ADC since P[C]=D and P[D]=A
MinimumPath (A, D) = AD since P[D]=A
MinimumPath (A, E) = ADCE since P[E]=C, P[C]=D and P[D]=A
Finally, the minimum path that includes all the vertices of the graph is ADCE.
Pseudocode
Priority queue
DIJKSTRA (Graph G, source_node s)
for you∈ V[G] to do
INFINITY
father[u] = NULL
distancia[s] = 0
add (glue, (s,distance[s]))
while queue is not empty do
u = extract_min(Queue)
for everyone v∈ adjacency to do
if distance[v] > distance[u] + weight(u, v) then
distance[v] = distance[u] + weight(u, v)
father[v] = u
add(glue,(v,distance[v]))
//boolean vector to control the vertices that have already been have
the minimum distance
for each w∈ Do V[G]
If (there is no edge between s and w) then
Infinity //you can mark the box with a -1 for
example
Serial Number
weight(s, w)
finally yes
end for
distancia[s] = 0
certain
n is the number of vertices that the Graph has
while (not_seen_all) do
vertex = take_the_minimum_of_the_distance_vector that has not been seen;
view[vertex] = true;
for each w∈ successors (G, vertex) do
if distance[w] > distance[vertex] + weight(vertex, w) then
distance[w] = distance[vertex] + weight(vertex, w)
end if
end for
end while
end function
External links
Template:Commons
Categories:
Pages with broken links to files
Informatics
Programming
Algorithms
Unable to access the content of the provided link.