Precompute all paths in the graph when the graph changes and when it is constructed.