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 , which satisfies the triangle inequality, enabling the second property of .
Ex. 3
For a cycle we are given . It is natural to ignore the case .
Recall the facts
- for path
Lemma.
If any then , 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 . Nothing to be done.
Case . Check to see if new paths including edge offer less-weight.
(For LaTeX issue we denote matrix by )
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 is the same, and same for its recursive vertices. Similarly to .
Complexity.
Case . For paths which do not depend on , Nothing needs to be updated about them. If their paths are less or equal than any path which includes then obviously these paths are still optimal when the weight of increases. If for vertex , then shall never visit edge $\set{i,j\}$.
Our focus starts on vertices whose equals . For each such and each arbitrary vertex , We compute minimum paths from to and update if needed. Let and 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 by )
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.
b
c
In the same mannger matrices and are maintainces distances and predecessors, We maintain also matrix for the number of edges corresponding to in . The algorithm then checks before updating a new solution whether its number of edges is at most .
Complexity. The overhead is constant over the original algorithm. In terms of parameters and is postponed.
d
The algorithm constructs a series of matrices where , indicating shortest-paths of edges length at most . The adapted algorithm terminates on 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, and , Then we can construct a minimum spanning tree whose weight is less than either of them.
We define:
- , An edge in
- , An edge in
Lemma. For an edge , and are connected by a path in which does not include edge . Similarly for .
Follows immediately as by definition .
Lemma. For an edge , There exists distinct edges and such that joins and joins in . Similarly for .
Follows immediately by Lemma 1. Note the two edges and can share at most one vertix.
Lemma. If there is a cycle where all edges are in except exactly one edge in , and for some in the cycle, then we can construct a MST of weight less than
Consider two vertices, and , whose connectivity relies on edge . The path is . By adding we know there is path , i.e can reach without edge . Therefore we can form an alternative path for and without relying on by . Thus, Removing is safe. Note It is clear neither nor contains edge as that means there is an unnecessary cycle in the path.
Clearly is non-empty, Otherwise . Without the loss of generality, Assume the selected element of is . There are only two cases regarding the weight of .
Case 1: . By Lemma 1 we know there is a path which does not include . Clearly have a circle of, edges in and exactly one edge in . Since all weights of the graph are distinct and non-negative, is strictly less than all edges in the circle. By Lemma 3, We can form a lower-weight MST. Contradiction.
Case 2: . By Lemma 2 we get edges and in where they contain vertices and . Clearly it is not possible for both and to be in . Otherwise we would have a cycle in contradicting the fact a tree has no cycles. It is easy to justify it by considering . Without the loss of generality assume , i.e . Denote by .
We claim there is a cycle of edges including and , Where all remaining edges are in . By connectivity of we know there is a path in between and . Note the cycle is totally legit if it contained . Similarly, There is a cycle of edges including and , Where all remainig edges are in .
We know . 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 , There is a unique sub-graph , Such that for any cycle in whose all edges are in except for exactly one edge , The weight of is the maximum along the whole cycle of . 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:
d
Correctness. Yes. The proof is nearly identical to a.
Algorithm Description.