CO453: Network Design – Winter 2007
Instructor: Chaitanya Swamy
Solutions to Assignment 1
Throughout
G
= (
V, E
) with

V

=
n,

E

=
m
.
Q1:
The algorithm we will design will be very similar to Dijkstra’s algorithm.
Let
s
denote the
starting point, and
d
(
v
) denote the time taken to travel from
s
to
v
along the fastest path, i.e.,
d
(
v
) = min
s
v
paths
P
T
(
P
), where
T
(
P
) is the time taken to travel along path
P
. Observe that
analogous to shortestpath distances, we now have
d
(
v
)
≤
f
e
(
d
(
u
)) for every edge (
u, v
), and this
will form the basis of our greedy algorithm. As in Dijkstra’s algorithm, we will maintain a set
S
of “explored” nodes, the ones for which we have correctly calculated
d
(
v
), and we will maintain a
label
(
v
) for the nodes not in
S
, which is our current estimate for the least time taken to reach
v
from
s
. We will update
(
v
) based on the above rule but only consider edges (
u, v
) where
u
∈
S
,
then pick the node
w /
∈
S
with smallest
(
.
) value and add it to the set
S
, and repeat.
1) Initialize
S
← {
s
}
with
d
(
s
) = 0. Set
(
v
) =
∞
for all
v /
∈
S
.
Let
v
*
=
s
. [
v
*
denotes the last node added to
S
.]
2) While
S
=
V
,
(a) For every edge
e
= (
v
*
, v
) where
v /
∈
S
, update
(
v
)
←
min
(
v
)
, f
e
(
d
(
v
*
)) .
(b) Let
w /
∈
S
be such that
(
w
) = min
v /
∈
S
(
v
).
(c) Set
S
←
S
∪ {
w
}
, d
(
w
) =
(
w
)
, v
*
=
w
.
Here we have presented the improved implementation done in class that yields a better running
time. The proof of correctness and runningtime analysis also proceed as in Dijsktra’s algorithm.
Consider any node
w
, and the set
S
just before
w
is added to it (in step 2(c)).
First, note that
there is an
s
w
path
P
w
such that the time taken to travel along
P
w
is
d
(
w
).
Note that
d
(
w
) =
(
w
) = min
u
∈
S
:(
u ,w
)
∈
E
f
u ,w
(
d
(
u
)
)
, so if
u
∈
S
is the node that attains the minimum in
(
w
), then
P
w
is obtained by adding the edge (
u , w
) to the path
P
u
(which is obtained recursively).
(We can easily keep track of these paths in the algorithm.) Now we show that
d
(
w
) is indeed the least
time taken to reach
w
along any
s
w
path. Consider any
s
w
path
P
. Let
v
be the first node on
P
that is not in
S
, and
u
∈
S
be the node on
P
just before
v
. Let
P
be the portion of path
P
from
s
to
v
. Let
t
1
and
t
2
be the times at which we reach
u
and
v
respectively by traveling along path
P
.
In Dijsktra’s algorithm, we used the fact that edge costs are nonnegative to argue that the cost of
P
is at least the cost of
P
. Similarly, we will lower bound
T
(
P
) here using the given properties of
the
f
e
functions. Let
e
1
= (
v, v
1
)
, e
2
, . . . , e
k
= (
v
k

1
, w
) be the portion of path
P
from
v
to
w
. Then
the time taken to reach
w
by traveling along
P
is
T
(
P
) =
f
e
k
(
f
e
k

1
(
. . . f
e
2
(
f
e
1
(
t
2
))
. . .
))
≥
t
2
since
f
e
(
t
)
≥
t
for every edge
e
. Also,
t
2
=
f
u,v
(
t
1
)
≥
f
u,v
(
d
(
u
)
)
since
t
1
≥
d
(
u
) and the
f
e
functions are
monotonic. Thus, we have
T
(
P
)
≥
f
u,v
(
d
(
u
)
)
≥
(
v
)
≥
(
w
), where the last two inequalities follow
from the definition of the
(
.
) values, and since we choose
w
to add to the set
S
. This holds for any
path
P
, which completes the correctness proof.