Graph Theory Solution for Microsoft bridge Problem
Microsoft's bridge problem is that four people have to use a flashlight when crossing a bridge at night. There is only one flashlight, and at most two people can pass each time, the speed of the four people crossing the bridge is 1 minute, 2 minutes, 5 minutes, and 10 minutes respectively. How long does it take for four people to go through the bridge at least?
If graph theory is used for modeling, a directed graph can be constructed using the state of four people at both ends of the bridge as nodes, as shown in, the state of the person who has crossed the bridge is used as the node of the graph. At the beginning, no one bridges the bridge. Therefore, it is expressed as null. In the first round, two people bridge the bridge and there are 6 possible combinations: (1, 2) (), it takes 2, 5, 5, 10 minutes to switch from an empty state to these states, time is used as the weight of a directed edge. When two people bridge the bridge, they need to take a flashlight back to pick up other people. There are four possible situations: 1, 2, 5, 10, one of them stayed on the other side of the river, (1, 2) this state can only be converted to (1) (2) two states, the corresponding edge weight is 2, 1 minute, (1, 2) to (1) it takes 2 minutes to return the result, and the following graph theory model can be created. It is required to determine the minimum length of time for four people to use Xiaoqiao. In fact, the shortest path between (empty) nodes and (1, 2, 5, 10) nodes is obtained in the figure.
According to the Dijkstra shortest path algorithm, it is easy to find the shortest path, as shown in the crude line. In this way, the total time is 2 + 1 + 10 + 2 + 2 = 17 minutes, so if we can learn Graph Theory live, this kind of intellectual problem becomes an entry-level question of graph theory.