Shortest map

Shortest map

For some time can only operate on the shortest path and the shortest possible problem of multiple same time, we build the shortest path map method can be used: is to put a new edge on the chart among the shortest path, so that problems can be in one the DAG (directed acyclic graph) operation.

Specific method: If we shortest FIG request from 1 to n, can start with a single source node 1 over the shortest run , and then run it again from the single-source shortest n , (the shortest run twice), then enumeration each node, if it is the shortest path from node 1 to the node n plus the shortest is equal to its shortest path from node 1 to node n, then the point on the shortest path in FIG.

Guess you like

Origin www.cnblogs.com/LianQ/p/11232670.html