Pseudo Code
- When looking to visit a new vertex, we choose the vertex with the smallest known distance first.
- Once we’ve moved to this vertex, we look at each of its neighbors.
- For each neighboring vertex, we calculate the distance from the starting point by summing all the edges that lead from the start to the vertex in question.
- If the new total distance to the vertex is less than the previous total, store the new, shorter distance for that vertex.
Essentially you need to track:
- each vertex and its shortest distance to the start node
- the vertices that have been visited
- an object containing a value of each vertex and a key of the previous vertex we visited to get to that vertex