Sol hw4
Sol hw4
Solutions to Homework IV
s b d f h i k t
c g v
(a) Compute the total number of shortest paths between nodes s and t using the top-down algo-
rithm discussed in class.
(b) Compute the total number of shortest paths between nodes s and t that don’t contain node v,
again using the top-down algorithm discussed in class.
(c) Using the answers from (a) and (b), compute the total number of shortest paths between nodes
s and t that contain node v.
Solution:
Part (a): The following figure shows the graph above, with the integer appearing in parentheses
next to the node’s name giving the number of shortest paths from s to that node. These numbers
have been computed using the top-down algorithm discussed in class.
s (1)
(3) d
h (9)
i (9)
t (27)
1
Part (b): The following figure shows the graph above with node v deleted. Again, the integer
appearing in parentheses next to the node’s name is the number of shortest paths from s to that
node.
s (1)
(3) d
h (9)
i (9)
k (9) j (9)
t (18)
Thus, the total number of shortest paths between s and t that don’t contain node v is 18.
Part (c): From the results of Parts (a) and (b), it follows that the total number of shortest paths
between s and t that contain node v is 27 − 18 = 9.
Problem 2: The following table shows the values of functions f (x) and g(x) for various values of
the independent variable x.
x f (x) x g(x)
5.00 252822.43 3.00 5824779.30
7.50 84599.77 5.10 1185913.90
11.25 28308.89 8.67 347172.77
16.88 9472.76 14.74 114200.30
25.31 3169.79 25.06 40746.59
37.97 1060.68 42.60 17235.83
56.95 354.93 72.41 69248.85
85.43 118.77 123.10 384.66
128.14 39.74 209.27 10.41
192.22 13.30 355.76 0.13
By plotting these functions suitably, determine whether each of the above functions exhibits a
power-law behavior. If yes, determine the power-law exponent.
2
Solution: Log-log plots of functions f (x) and g(x) are shown below.
1x106 1x107
1x106
100000
100000
Value of g(x)
Value of f(x)
10000
10000
1000 1000
100
100
10
10
1
1 0.1
1 10 100 1000 1 10 100 1000
Value of x Value of x
Since the log-log plot for the function f (x) is a straightline, it exhibits a power-law behavior.
However, g(x) does not exhibit a power-law behavior.
To compute the power-law exponent for f (x), we will consider the values (11.25, 28308.89) and
(16.88, 9472.76). The slope of the line joining these two points in the log-log plot is given by
Problem 3: Suppose G is a connected undirected graph. Let ρ and ∆ denote respectively the
radius and diameter of G. Prove that ∆ ≤ 2ρ.
Solution: To establish the result, we will show that for any pair of nodes u and v, the shortest
distance is at most 2ρ.
Consider any pair of nodes u and v. Let p be a center of the graph. From the definitions of
center and radius, the distance between p and u is at most ρ and that between p and v is at most
ρ. In other words, there is a path of length at most 2ρ between u and v (passing through p). Hence
the shortest distance between u and v cannot be larger than 2ρ, and this completes the proof.
Note: It is easy to construct an example where the diameter of the graph is exactly twice the
radius. (For example, consider a simple path with three nodes. The middle node of the path is the
center and so the radius is 1. The diameter is 2, which is the shortest distance between the two
end nodes.)