Subroutine FindPathTree finds the shortest path tree rooted at a particular node. By following links from a destination node back through the tree, you can trace the shortest path from the root node to the destination node.
The basic idea is this. The routine keeps a candidates collection that holds nodes that are one link away from a node in the current shortest path tree. It keeps track of the best distance so far to every node in the shortest path tree and in the candidates collection.
While the candidates collection is not empty, the program finds the node in the collection with the shortest distance to the root node. Because that node is the closest one to the root, adding other nodes to the shortest path tree cannot improve the path to this node. The program adds that node to the shortest path tree and removes it from the candidate list.
Next the program considers all of the neighbors of the newly added node. If the path to a neighbor via this node is shorter than the path it has currently recorded to the root node, then the program updates the neighbor's path to use the newly added node and then adds it to the candidates collection (if it is not already in the collection).
The program continues this proces, removing a node from the candidates collection, adding it to the shortest path tree, and adding its neighbors to the candidates collection until the collection is empty. At that point the shortest path tree is complete.