Dijkstra's algorithm: Difference between revisions

m
added whitespace and highlighting to the task's preamble, used a larger font when referencing two specific vertices.
m (added whitespace and highlighting to the task's preamble, used a larger font when referencing two specific vertices.)
Line 2:
 
<br>
'''Dijkstra's algorithm''', conceived by Dutch computer scientist [[wp:Edsger Dijkstra|Edsger Dijkstra]] in 1956 and published in 1959, is a [[wp:graph search algorithm|graph search algorithm]] that solves the single-source [[wp:shortest path problem|shortest path problem]] for a [[wp:graph (mathematics)|graph]] with nonnegative [[wp:edge (graph theory)|edge]] path costs, producing a [[wp:shortest path tree|shortest path tree]]. &nbsp; This algorithm is often used in [[wp:routing|routing]] and as a subroutine in other graph algorithms.
 
For a given source [[wp:vertex (graph theory)|vertex]] (node) in the graph, the algorithm finds the path with lowest cost (i.e. the shortest path) between that vertex and every other vertex. &nbsp; It can also be used for finding costs of shortest paths from a single vertex to a single destination vertex by stopping the algorithm once the shortest path to the destination vertex has been determined. For example, if the vertices of the graph represent cities and edge path costs represent driving distances between pairs of cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route between one city and all other cities. As a result, the shortest path first is widely used in network [[wp:routing protocol|routing protocol]]s, most notably [[wp:IS-IS|IS-IS]] and [[wp:OSPF|OSPF]] (Open Shortest Path First).
 
For example, if the vertices of the graph represent cities and edge path costs represent driving distances between pairs of cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route between one city and all other cities. &nbsp; As a result, the shortest path first is widely used in network &nbsp; [[wp:routing protocol|routing protocol]]s, most notably &nbsp; [[wp:IS-IS|IS-IS]] &nbsp; and &nbsp; [[wp:OSPF|OSPF]] &nbsp; (Open Shortest Path First).
 
 
;Task:
# Implement a version of Dijkstra's algorithm that computes a shortest path from a start vertex to an end vertex in a directed graph.
# Run your program with the following directed graph to find the shortest path from vertex "&nbsp; <big> '''a"''' </big> &nbsp; to vertex "&nbsp; <big> '''e'''." </big>
# Show the output of your program.
{| class="wikitable" style="text-align: center; float: left"