Sei sulla pagina 1di 2

Exercises 1. Minimum spanning trees and shortest paths.

1. Given a complete graph with vertex set {A, B, C, D, E, F } and the following weights
on the edges.
A B C D E F
A 0 6 9 11 5 9
B 6 0 3 6 5 2
C 9 3 0 0 4 4
D 11 6 0 0 5 6
E 5 5 4 5 0 8
F 9 2 4 6 8 0

a. Determine a minimum spanning tree with Kruskal’s algorithm.


b. Determine a minimum spanning tree with Prim’s algorithm starting in F .
c. Determine the shortest paths from F to all other vertices by use of Dijkstra’s
algorithm.

2. Given a connected undirected graph G with positive weights on the edges. By use
of Dijkstra’s algorithm, all shortest paths starting at vertex r have been found. The
union of these paths forms a tree, which we will call the Dijkstra tree at r.

a. Give an example of a weighted graph, whose minimum spanning tree differs


from all its Dijkstra trees.
b. Prove that a minimum spanning tree and a Dijkstra tree of G always have at
least one edge in common.

3. At each step of Kruskal’s algorithm it has to be checked if the candidate edge creates
a circuit. Think of a way to implement this, and deduce un upper bound for the
complexity of the algorithm as a function of the number of vertices.

4. If some arcs of a directed graph D have negative length, but no circuit has a negative
length, then there exists a shortest path between any two nodes of D. However,
Dijkstra’s algorithm does not work anymore.

a. Give an example that illustrates this.


b. Why doesn’t it help if we make all weights nonnegative by adding a constant
to all given weights ?
c. Do these remarks also hold for Prim’s algorithm ?

5. In a directed communication network, a message is send from a node a to another


node b. At each arc (i, j) of the network there is a probability pi,j that the message
will get lost on this arc. These probabilities are fixed and independent. The network
manager wants to choose a path from a to b, such that the probability that the
message gets lost on this path is minimal. Translate this problem into a shortest
path problem. Can this problem be solved with Dijkstra’s algorithm?

1
6. The table below gives the weights (lengths) w(x, y) of the arcs in a directed graph
(x corresponds to the row, and y to the column).

A B C D E F
A 0 8 8 8 8 2
B 8 0 −2 7 6 2
C 8 4 0 3 2 3
D 8 4 0 0 −1 4
E 8 2 2 3 0 8
F 8 3 2 −1 4 0

a. Use the method of Bellman-Ford to determine a shortest path from A to C, or


a negative circuit if such a path does not exist.
b. Use the method of Floyd to determine a shortest path from A to C, or a
negative circuit if such a path does not exist.
c. Same questions, but now with w(C, D) = 0.

Potrebbero piacerti anche