Implement algorithm for shortest paths in terms of edges

Uses BFS's spanning tree to find the paths from any vertex in the tree
to the root.