build() is slow
Building new nodes is slow, most likely due to all of the graph searches.
- For each node
- Keep track of all reachable nodes, sorted by distance, as well as the path to each one
- This should be updated when new nodes are added or removed
- Update bfs to look through the relevant array
As an intermediate step, we should resolve the nodes
and edges
values before we call bfs() since they can be reused a lot