exercise

Shortest paths with cheating

a)

This algorithm runs the Dijkstra’s algorithm for every possible weight functions

  1. For every graph we use, the edges are directed with weight for all .
    • We can set at most edges to . Obviously we should fully use cheats, because the weights are non-negative.
    • For each cheat edge, we have choices. By the principle of combination, we have in total choices. This gives weight functions.
  2. We apply Dijkstra’s algorithm in on each graph from
  3. We find the shortest s-to-t-distance among the results of Dijkstra’s algorithm from all the graphs. This takes , since there are graphs.
  4. For each iteration we runs Dijkstra’s algorithm in and we have iterations. Plus the time in step 3 we have
b)
  1. We construct a new . consists of copies of . Each copy of are still connected in the same way as (with the same weight in ). We denote each copy as with . For , each vertex in has extra edges pointing to the neighbors of the corresponding vertex in upper layer . These extra edges all have the weight
  2. We apply Dijkstra’s algorithm in on this graph from
  3. We extract the result by getting the distance to from the result of the Dijkstra’s algorithm
  4. The total runtime costs . We can ignore the cost in step 3 because it takes constant time to extract the result.

11.4 Driving from Zurich to Geneva

a)
  1. We use a directed graph where is the vertex set representing the cities. is the edge set representing each highways. Note that each direction of a highway is considered as a distinct edge. The weight of an edge is the cost of the fuel for this part minus (if exists) the money earned by taking a passenger for this part.
  2. We apply Bellman-Ford algorithm on this graph from vertex Zurich
  3. We extract the result by getting the distance to vertex Geneva.
  4. The running time is (the running time of Bellman-Ford algorithm). The running time in Step 1 and 3 are and , and therefore can be ignored.

11.5 Ancient Kingdom of Macedonia

He does not need to reconsider.

We first model this problem. The kingdom can be treated as a connected graph with is the vertex set representing the cities, and representing the Roman roads. In the first year, the cost of an asphalt edge is just its length . and the optimal asphalt network is the minimal spanning tree. Let be the set of the asphalt edge. This MST has the cost . In the second year the cost of each asphalt node becomes where is a constant. The question is if is still a MST. The cost of is now . The number of edges of a spanning tree is always . Since the number of cities does no change in year 2, must be a constant. We know that is already optimized, so there cannot exist a new such that . Therefore must also be optimized. Hence, is still a MST in year 2. We now proved that (the set of asphalt road) does not need to be changed in year 2.