\newcommand{\ddfrac}[2]{\frac{\displaystyle{#1}}{\displaystyle{#2}}}

Exercises

Ex. 1

skipped in hope of professionally read while solving the exercises, and well-gain from lectures.

Ex. 2

To definte shortest-path weight function δ\delta, which satisfies the triangle inequality, enabling the second property of w\overline{w}.

Ex. 3

For a cycle c=v0,v1,,vk=v0c = v_0, v_1, \dots, v_k=v_0 we are given w(c)=0w(c) = 0. It is natural to ignore the case k=0k = 0.

Recall the facts

  1. w(u,v)0\overline{w}(u,v) \geq 0
  2. w(u,v)=w(u,v)+h(u)h(v)\overline{w}(u,v) = w(u,v) + h(u) - h(v)
  3. w(p)=w(p)+h(v0)h(vk)\overline{w}(p) = w(p) + h(v_0) - h(v_k) for path pp

Lemma.Σw(vi,vi+1)=0\Sigma \overline{w}(v_i, v_{i+1}) = 0

w(c)=w(c)+h(v0)h(vk)=0+h(v0)h(v0),v0=vk=0\begin{aligned} \overline{w}(c) &= w(c) + h(v_0) - h(v_k) \\\\ &= 0 + h(v_0) - h(v_0), v_0=v_k \\\\ &= 0 \end{aligned}

If any w(vi,vi+1)>0\overline{w}(v_i,v_{i+1}) > 0 then w(c)>0\overline{w}(c) > 0, contradicting the proved above lemma.

Ex. 4

skipped in hope of professionally read while solving the exercises, and well-gain from lectures.

Ex. 5

In page 636 there is a hint of using fibonacci-heabs. I am not sure whether it is the key of solving the problem. Anyway, The exercise is postponed untill we gain a guidance from others. Skimming the chapter did not yield any promising clue to pursue.

Ex. 6

Same as Ex. 5

Problems

Prob. 1

a

Case r=wi,jr = w_{i,j}. Nothing to be done.

Case r<wi,jr < w_{i,j}. Check to see if new paths including edge (i,j)(i,j) offer less-weight.

(For LaTeX issue we denote matrix Π\Pi by PP)

for x = 0 to n
  for y = 0 to n
    if d_x,i + r + d_j,y < d_x,y
      d_x,y = d_x,i + r + d_j,y
      P(x,j) = i
      P(x,y) = P(j,y)

Observe Π(x,i)\Pi(x,i) is the same, and same for its recursive vertices. Similarly to Π(j,y)\Pi(j,y).

Complexity. O(V2)\mathcal{O}(V^2)

Case r>wi,jr > w_{i,j}. For paths which do not depend on wi,jw_{i,j}, Nothing needs to be updated about them. If their paths are less or equal than any path which includes wi,jw_{i,j} then obviously these paths are still optimal when the weight of wi,jw_{i,j} increases. If for vertex xx, P(x,j)!=iP(x,j) != i then xx shall never visit edge $\set{i,j\}$.

Our focus starts on vertices xx whose Π(x,j)\Pi(x,j) equals ii. For each such xx and each arbitrary vertex yy, We compute minimum paths from xx to yy and update if needed. Let DD' and Π\Pi' denote minimum distance and predecessor matrices after updating the weight of edge $\set{i,j\}$ to $r$, respectively. Any path $x \rightarrow y$ either consists of a single edge $\set{x,y\}$ or contains an intermediate vertex between $x$ and $y$. We loop on all vertices $z$ to compute $D(x,z) + D(z,y)$ and then set $D'(x,y)$. However, we must check whether edge $\set{i,j\}$ falls into the path $x \rightarrow z$ or $z \rightarrow y$. if NO, then we know $D'(x,z) = D(x,z)$ and $D'(z,y) = D(z,y)$. If YES, then the new weight of path $x \rightarrow y$ which equals $D(x,y) + (r-w_{i,j})$, is equal or less than the new weight $D(x,z) + D(z,y) + (r - w_{i,j})$. That follows by $D(x,y) \leq D(x,z) + D(z,y)$ as the additional weight $r - w_{i,j}$ is added on both sides of the inequality. In this case we know $z$ won’t offer a less-weight path. So we can restrict our focus on vertices $z$ whose corresponding paths do not include edge $\set{i,j\}$.

(For LaTeX issues we denote matrix Π\Pi by PP)

isEdgeInPath(edge {i,j}, path x -> y, predecessor P)
      if P(x,j) != i
        return False

      s = y
      while P(x,s) != x
        if P(x,s) == j
          return False

      return True

Main()
      for x = 0 to n
        if P(x,j) = i
          for y = 0 to n
            minDistance = min{ edge (x,y) if exists, D(x,y) + (r - w_i,j) }
            minVertex = NULL
            isDistanceUpdated = False
            for z = 0 to n
              if isEdgeInPath( {i,j}, x -> y, P) OR z = x OR z = y
                continue to next iteration of z

              zDistance = D(x,z) + D(z,y)
              if (distance < minDistance)
                minDistance = zDistance
                minVertex = z
                isDistanceUpdated = True

             if isDistanceUpdated
               P'(x,y) = P(z,y)
               P'(x,z) = P(x,z)

Complexity. O(V3)\mathcal{O}(V^3)

b

image

c

In the same mannger matrices MM and Π\Pi are maintainces distances and predecessors, We maintain also matrix WW for the number of edges corresponding to di,jd_{i,j} in MM. The algorithm then checks WW before updating a new solution whether its number of edges is at most hh.

Complexity. The overhead is constant over the original algorithm. In terms of parameters and hh is postponed.

d

The algorithm constructs a series of matrices L1,L2,..,Ln1L^1, L^2, .., L^{n-1} where Lm=(lijm)L^m = \left ( l_{ij}^m \right ), indicating shortest-paths of edges length at most mm. The adapted algorithm terminates on LhL^{h} and outputs it.

Complexity. At most the complexity of the original algorithm.

e

Prob. 2

a

We prove if there are two different minimum spanning trees, TaT_a and TbT_b, Then we can construct a minimum spanning tree TcT_c whose weight is less than either of them.

We define:

  • Ea=Ta(E)E_a = T_a(E)
  • Eb=Tb(E)E_b = T_b(E)
  • Ec=EaEbE_c = E_a \cap E_b
  • Eab=EaEbE_{a-b} = E_a - E_b
  • Eba=EbEaE_{b-a} = E_b - E_a
  • Ec=EabEbaE_{-c} = E_{a-b} \cup E_{b-a}
  • eae_{a}, An edge in EaE_a
  • ea0e_{a0}, An edge in EabE_{a-b}

Lemma.   For an edge ea0={x,y}e_{a0} = \{x,y\}, xx and yy are connected by a path in TbT_b which does not include edge ea0e_{a0}. Similarly for eb0e_{b0}.

Follows immediately as by definition ea0∉Ebe_{a0} \not\in E_b.

Lemma.   For an edge ea0={x,y}e_{a0} = \{x,y\}, There exists distinct edges eb1e_{b}^1 and eb2e_{b}^2 such that eb1e_b^1 joins xx and eb2e_b^2 joins yy in EbE_b. Similarly for eb0e_{b0}.

Follows immediately by Lemma 1. Note the two edges eb1e_{b}^1 and eb2e_{b}^2 can share at most one vertix.

Lemma.   If there is a cycle where all edges are in EaE_a except exactly one edge ebe_b in EbE_b, and w(eb)<w(eai)w(e_b) < w(e_a^i) for some eaie_a^i in the cycle, then we can construct a MST Ta=Taeai+ebT_a' = T_a - e_a^i + e_b of weight less than TaT_a

Consider two vertices, v1v_1 and v2v_2, whose connectivity relies on edge eai={x,y}e_a^i = \{x,y\}. The path is p(v1,x),(x,y),p(y,v2)p(v_1,x), (x,y), p(y,v_2). By adding ebe_b we know there is path p0(x,y)(x,y)p_0(x,y) \neq (x,y), i.e xx can reach yy without edge (x,y)(x,y). Therefore we can form an alternative path for v1v_1 and v2v_2 without relying on (x,y)(x,y) by p(v1,x),p0(x,y),p(y,v2)p(v_1,x), p_0(x,y), p(y,v_2). Thus, Removing eaie_a^i is safe. Note It is clear neither p(v1,x)p(v_1,x) nor p(v2,x)p(v_2,x) contains edge (x,y)(x,y) as that means there is an unnecessary cycle in the path.

Clearly EcE_{-c} is non-empty, Otherwise Ta=TbT_a = T_b. Without the loss of generality, Assume the selected element of EcE_{-c} is {x,z}=ea0Eab\{x,z\} = e_{a0} \in E_{a-b}. There are only two cases regarding the weight of ea0e_{a0}.

image

Case 1: w(ea0)=0w(e_{a0}) = 0. By Lemma 1 we know there is a path p(x,y)p(x,y) which does not include ea0e_{a0}. Clearly have a circle of, edges in EbE_b and exactly one edge in EaE_a. Since all weights of the graph are distinct and non-negative, w(ea0)w(e_{a0}) is strictly less than all edges in the circle. By Lemma 3, We can form a lower-weight MST. Contradiction.

Case 2: w(ea0)>0w(e_{a0}) > 0. By Lemma 2 we get edges eb1e_{b}^1 and eb2e_{b}^2 in EbE_b where they contain vertices xx and yy. Clearly it is not possible for both eb1e_b^1 and eb2e_b^2 to be in EaE_a. Otherwise we would have a cycle in TaT_a contradicting the fact a tree has no cycles. It is easy to justify it by considering Ta=Taea0T_a' = T_a - e_{a0}. Without the loss of generality assume eb1∉Eae_b^1 \not\in E_a, i.e eb1=eb01e_b^1 = e_{b0}^1. Denote eb01e_{b0}^1 by {y,z}\{y,z\}.

We claim there is a cycle of edges including eb0e_{b0} and ea0e_{a0}, Where all remaining edges are in EaE_a. By connectivity of TaT_a we know there is a path in TaT_a between xx and zz. Note the cycle is totally legit if it contained yy. Similarly, There is a cycle of edges including ea0e_{a0} and eb0e_{b0}, Where all remainig edges are in EbE_b.

We know ea0eb0e_{a0} \neq e_{b0}. In either cases some edge is greater than the other. By Lemma 3, We get a lower-weight spanning tree. Contradiction.

b

Correctness. For any graph GG, There is a unique sub-graph GcG_c, Such that for any cycle cc in GG whose all edges are in GcG_c except for exactly one edge exe_x, The weight of exe_x is the maximum along the whole cycle of cc. The proof is nearly identical to a.

Clearly the MST exerts this property lest we construct another spanning-tree of less weight. Since the algorithm claimed here always prefers less-weight edges, It shall never contradict that property also. By uniqueness the claimed algorithm yields the MST.

Algorithm Description.

Complexity Analysis.

c

Counter-example:

image

d

Correctness. Yes. The proof is nearly identical to a.

Algorithm Description.