Dijkstra’s Shortest Path
More precisely:
- For the node p just added to P, add each of its neighbors n to T such that:
- if n is not in T, add it, annotating it with p ’s ID and the cost to reach it through p
- if n already in T and path to n through p has lower cost, remove earlier instance of n and add new instance annotated with p ’s ID and cost to reach it through p
- Pick the node n that has the smallest cost in T and, if not already in P, add it to P. Use its annotation to determine the router p to use to reach n. If T is empty, done.