vimwiki/tech/Dijkstra.wiki

23 lines
1002 B
Plaintext
Raw Normal View History

2021-11-06 19:00:01 +00:00
= Dijkstra's Algorithm =
Dijkstra's Algorithm was created by Edsger W. Dijkstra, and is an algorithm
for finding the *shortest path between any two nodes in a graph*. This can be
thought of finding the best route from point A to point B on something like a
road map. This is also called a *routing protocol*.
Dijkstra's Algorithm is a [[greedy_algorithm]].
== Algorithm ==
1) Choose some initial node to start from. Create a set of distances from this
node to all other nodes, and set their distance to infinite. This algorithm
will change these distances and attempt to find the fastest way to each node.
2) Mark all nodes as 'unvisited'. All of these nodes are part of a set.
3) For the current node, consider all of its unvisited neighbors and calculate
the distance from the start node to this node.
- For example, if the current node is marked as a distance of 6 from the
starting node, and the edge of neighbor _N1_ has a distance of 2, then
N1's distance is 6+2 = 8