Dijkstra's algorithm
The minimum spanning tree on which traffic flows in the latter case is heuristically defined by Dijkstra's algorithm and Prim's algorithm.