6.006 Quiz 2 Solutions Name 8
Problem 4. A Series of Tubes [20 points] (2 parts)
Consider a network of computers represented by a directed graph G. Each vertex v ∈ V represents
a computer, and each edge (u, v) ∈ E represents a network link from u to v.
(a) Let each edge (u, v) in G have a weight w(u, v) ∈ (0, 1], representing the probability
that a packet going from u to v is successfully delivered. Give an efficient algorithm
to find the path along which a packet has the highest probability of reaching its desti-
nation (i.e., the path for which the product of the edge weights is maximized).
Hint: Transform the weights and use a shortest path algorithm.
Solution: Construct a new graph G
0
, letting w
0
(u, v) = − log w(u, v). Shortest
paths in G
0
correspond to highest probability paths in G, because
P
i
w
0
(v
i
, v
i+1
) =
−
P
i
log w(v
i
, v
i+1
) = − log (
Q
i
w(v
i
, v
i+1
)), which is minimized when the product
term is maximized.
The new weights are non-negative, so run Dijkstra’s algorithm on G
0
to find the highest
probability paths.
(b) Now, instead of weighted edges, consider weighted vertices. In other words, network
links never drop packets, but nodes might. Edges are not weighted, but each vertex
v has a weight w(v) ∈ (0, 1], representing the probability that an incoming packet is
not dropped by that node. Give an efficient algorithm to find the path along which a
packet has the highest probability of reaching its destination (i.e., the path for which
the product of the vertex weights is maximized).
Hint: Transform the graph and use the algorithm from part (a).
Solution: Construct a new edge-weighted graph G
0
by assigning each edge the
weight w
0
(u, v) = w(v), then run the algorithm from part (a).
Note 1: It’s reasonable to assume here that the weight of the source vertex, s, is 1,
because the originating computer won’t drop the packet. Even without this assump-
tion, the problem isn’t much harder—adjust the weight of each edge originating at s
by multiplying it by w(s).
Note 2: Using the weight function w
0
(u, v) = w(u) · w(v) is problematic because the
weight of each vertex, except for the source and the target, is included in two edges of
the path, so those vertices are double-counted.