Looks like a Shortest Path Problem to me. Can be solved with algorithms such as Dijkstra's Algorithm or the Floyd Warshall Algorithm