Essentially a shortest path problem but with graphs