Document 11045780

advertisement
^S^CHOrJ^^
%
5
(MiRAPIEs
MIT LIBRARIES DUJi,,
a
lillllilH
3
T080 oobooESfl
•^S
^I^AR
a
tH
j^
'>.
"'^^s-g
ALFRED
P.
WORKING PAPER
SLOAN SCHOOL OF MANAGEMENT
FASTER PARAMETRIC SHORTEST PATH
AND MINIMUM BALANCE ALGORITHMS
Neal
E.
Robert
Young,
E.
Tarjan
and
James
W.P. No. 3112-90-MS
B.
Orlin
January
11,
MASSACHUSETTS
INSTITUTE OF TECHNOLOGY
50 MEMORIAL DRIVE
CAMBRIDGE, MASSACHUSETTS 02139
1990
%
FASTER PARAMETRIC SHORTEST PATH
AND MINIMUM BALANCE ALGORITHMS
Neal
E.
Robert
Young,
E.
Tarjan
and
James
W.P. No. 3n2-90-MS
B.
Orlin
January
11,
1990
Faster Parametric Shortest Path and
Minimum Balance Algorithms
Neal E. Young
Robert E. Tarjan
'
January
5,
James B. Orlin
^
^
1990
Abstract
We
use Fibonacci heaps to improve a parametric shortest path algo-
rithm of Karp and Orlin, and we combine our algorithm and the method of
Schneider and Schneider's minimum-balance cilgorithm to obtain a faster
minimum-balance algorithm.
For a graph with n vertices and
m
edges, our parametric shortest path
algorithm and our minimum-balance algorithm both run
'Computer Science Department, Princeton
in
0(nm +
University, Princeton,
NJ 08544, USA. Re-
University, Princeton,
NJ 08544, USA and
search supported by the Hertz Foundation.
'Computer Science Department, Princeton
NEC
Research Institute, Princeton, NJ 08540, USA. Research partiaUy supported by National
Science Foundation Grants
DCR-8605961 and STC 88-09648, and
Office of
Naval Research
Contract N00014-87-K-0467.
'Sloan School of Management, M.I.T., Cambridge,
supported by
NSF PYI
grant 8451517-ECS,
Analog Devices, Apple Computers,
Inc..
AFOSR
MA
02139,
USA. Research
partially
grant AFOSR-88-0088, and grants from
and Prime Computer.
n^logn) time, improved from
0(nm log n)
for the
path algorithm of Karp and Orlin and O(n^m)
parametric shortest
for the
minimum-balance
algorithm of Schneider and Schneider.
An important
is
in
finding a
application of the parametric shortest path algorithm
minimum mean
cycle.
Experiments on random graphs
suggest that the expected time for finding a
our algorithm
1
is
0{n
log n
+
minimum mean
cycle with
m).
Introduction
The body
of the paper contains fi%e sections.
The
parametric shortest path problem and an algorithm
0{nm +
rj-
logrj)-time on an n-vertex graph with
based on an
0(nm log n)-lime
section describes the
first
for solving
m
edges
it
that runs in
The algorithm
is
algorithm of Karp and Orlin [K081], modified
to take advantage of the Fibonacci heap data structure of
Fredman and Tarjan
[FT87].
The second
section describes the
minimum mean
cycle
parametric shortest path algorithm can be used to solve
The
third section describes the minimum-balauice
for solving
the
it
that runs in
0{nm +
n^ logn)-time.
method of Schneider and Schneider
0(n-m)-time algorithm
gorithm.
for the
[SS87],
problem and how the
it.
problem and an algorithm
The algorithm combines
which yields a straightforward
problem, with the parametric shortest path
al-
The
fourth section describes the results of implementing the parametric
shortest path algorithm for finding a
random graphs The
cycle and running
it
on
results suggest that the expected time for the parametric
minimum mean
shortest path algorithm to find a
and that even
minimum mean
graphs the algorithm
for small
is
cycle
faster
is
close to
0(m + n log n),
than the 0(nrn)-time
al-
gorithm of Karp [Kar78].
A
solution to the parametric shortest path algorithm
is
given by a sequence
of trees, which our algorithm generates but does not store.
discusses
how
the trees
may
of the problems to which our algorithms
the final section are generalizations
in
still
apply.
Parametric Shortest Paths
The parametric
shortest path problem
source shortest path problem
subtracted from them.
An
weighted, directed graph
G=
able from
s,
in
is
a generalization of the standard single-
which some of the edge costs have a parameter
instance of the problem
(
V,
£,
c),
a source vertex
s
specified by giving a
with
all
vertices reach-
Specifically, a particular value A of
the parameter yields the weighted, directed graph
X6E'){e)
is
and a subset E' of the edges representing those edges whose costs
have the parameter subtracted from them.
(c-
final section
be implicitly stored so that any tree in the sequence
can be generated quickly. Also considered
2
The
=
c(e)
-
A(5£-(e),
and 6E'{e)
=
1
Gx = {V,E,c-
if e
€ £" and
\8e'), where
otherwise.
(We
adopt the convention that
on shortest paths
The problem
shortest paths
Gx
in
problem
is
where A*
is
subtracted because then influence
to determine a shortest path tree in
Gx
are well defined
parameter
the graph increeises with the parameter.)
in
is
tlie
are well defined.
if
and only
if
Ca
It is
all
A,
Gx
then we take A*
for all A,
G
those that are shortest
in
A*
= — oc,
G among
that shortest paths in
Thus the
such that A G [—oc, A'],
=
among
of parcimeterized edges. Similarly,
we take
every A such that
G>. has no negative-cost
shortest paths to be those that are shortest in
maximum number
for
contains no negative-cost cycle.
large as possible such that
has no negative-cost cycle
cycle for
known
well
to determine a shortest path tree for each
is ais
Gx
if
In Goc.
oo.
Ga
we take
those that have the
Gx has
and take shortest paths
those which have the
cycle. If
a negative cost
to be
G_oo
in
minimum number
of
parameterized edges.
A
and a
\k
=
solution to the problem
finite
is
given by a finite sequence of trees To,7"i,
non-decreasing sequence of real numbers
A' such that T,
is
a shortest path tree
in
Gx
— oo =
for all
Aq
A
in
<
Ai
<
.
.
•
.
7"^
,
•
[A,,A, + i].
<
A
solution could also be given by a sequence of trees and strictly increasing real
numbers. The algorithm we give may produce sequences with some
A,^.]. If
the second type of solution
is
desired, such A,
A,
equal to
and the corresponding
7;
can simply be removed from the sequence.
Applications of the parametric shortest path problem include the
minimum
concave-cost dynamic network flow problem [G085], matrix scaling [OR85,
SS89], and the
minimum mean
cycle and
minimum
balancing problems,
dis-
cussed below.
An
2.1
A
Inductive
natural metliod for soivmg the parametric shortest path problem
tree by tree.
A,
and
tree
That
This
T,.
The
—
Method
is
first tree
from
5Zeg£
s
determine To and then inductively determine successive
is,
method
the
To for Aq
we
that
= — oc
can be determined by finding a shortest path
k(e)|- For this value of the parameter, paths with fewer
less
a shortest path tree
G-oo
able to detect the case
when
The
shortest path algorithm that
<
parameterized
than paths with more, so a shortest path tree
in
is
in
Gq
is
also
used must be
a negative cost cycle exists (shortest paths are not
well defined), for this will be the case
if
A'
= — oo.
Pivot Paths
Next we consider the induction
tree
use.
by running any standard 0(nin)-time algorithm on Gq, where q
edges always cost
2.2
to proceed
is
from
s in
step.
Suppose that
tree
T
is
G\. Consider increasing the parameter from A
value A' beyond which
T
vertex v becomes shorter than
is
its
that
some path p not
counterpart
t^
in
(the path
In order for this to happen, p must be equal in cost to
t^ in
until
it
reaches a
The reason
ceases to be a shortest path tree.
ceases to be a shortest path tree
a shortest path
T
from
from
s
that
s to
T
some
to v) in T.
Gas and have more
parameterized edges than
<i,
We
.
call A'
the ptvoi point from T, and any such
path p a pivoi path for T.
How
—
can we find a pivot path
a shortest path
in
Gy
with more param-
— without knowing A'?
eterized edges than the corresponding path in
T
way would be
with more parameterized edges
than
its
corresponding path
become equal
will
increcised,
we
will
in
cost to
and
their
its
its
Of
these paths,
we choose one that
if
corresponding path
pivot path p for T,
because the costs of p and
Gy, p and
T.
in
s
in
T
as the
parameter
f,
we can determine the pivot point
is
A',
can coincide at only one value of the parameter.
counterpart
<,
'"
^
corresponding prefixes are
*re both shortest paths,
of equal cost.
all
Thus
are shortest paths. If we obtain the subgraph T' by deleting
all
all
and thus they
paths
in
edges of
lead into vertices of p and adding the edges of p, then, provided T'
is
first
have a pivot path.
Once we know a
In
p from
to consider each path
One
is
TUp
T
that
a tree,
it
a shortest path tree in Gx'.
To make
will rule
sure
we
are
making progress
out degenerate pivot paths
in discovering the
subgraph T'
,
we
those with a proper prefix with fewer
-
parameterized edges than the corresponding path
in
T or
with a zero cost cycle
with no parameterized edges. From any degenerate pivot path we can construct
a non-degenerate pivot path by replacmg the offending proper prefix by the
corresponding path
paper when we
in T, or
by deleting the offending cycle. For the rest of the
refer to a pivot
path we
will
6
mean a non-degenerate
pivot path.
This gives us the following algorithm. Determine an
Look
To for C-oo
for a
initial
(non-degenerate) pivot path p for Tq.
stop. Otherwise, use this patli to determine the pivot point
If
T'
is
not a tree, stop.
shortest path tree
If
there
is
none,
and a subgraph T'
Otherwise take T' to be the next shortest path tree
and continue.
If
the algorithm stops because there are no pivot paths, then the current
shortest path tree will continue to be a shortest path tree indefinitely as the
parameter
is
increased, and X'
Otherwise, the algorithm
T'
is
may
oc.
stop because T'
formed by replacing the edges
path with the pivot path edges
a cycle,
p. a
=
and can only contain
the tree
in
T
Thus T' can only
a cycle
shortest path, contains a cycle,
if
it
is
not a tree.
The subgraph
into the vertices
on the pivot
fail
to be a tree
if it
the pivot path
p contains a
cycle.
must be a zero cost
cycle. Since
contains
p
But
non-
is
degenerate, the cost of the cycle must be decreasing with the patfaxneter.
if
Thus
the graph will have a negative cost cycle for any larger value of the parameter,
and A-
=
Thus,
intervals.
A'.
if
the algorithm terminates,
To bound
the
number of
it
trees
gives a correct sequence of trees
and
produced by the algorithm, consider
T
the
number
By
the construction of T" and the non-degeneracy of the pivot path, the path
of parameterized edges on the path into each vertex in
in T' into a vertex contains at least as
in T.
Furthermore, at least one vertex
many
in T'
and
T'.
parameterized edges as the path
has more parameterized edges on
its
path
T'
in
.
Thus the algorithm produces
most n^ (actuaJly n{n — l)/2)
at
trees.
A
2.3
we
First,
reduce
will
Suppose there
prefix that
tlie
number
of potential pivot paths the algorithm checks.
a (non-degenerate) pivot path, and
is
is still
proper prefix of p
least as
implementation
faster
p denote
let
is
not a pivot path, yet
many parameterized edges
T, and
we replace any proper
if
a pivot path.
counterpsirt in
In particular,
T
.
we obtain
by an edge (necessarily not
the path
some
in
p(e)
T
is
a shortest path
is
in
from
s to
prefix of
p by
we replace the
if
counterpart
e
=
.
its
in
in T).
For each edge
We
call
e.
=
e
Thus
(u, i) the value of the
(u.r)
if
T, we obtain
T
parameter,
t^,.
let
p by
its
followed
p(e) denote
any pivot path
exists,
any such p(e) a canonical pivot path.
we
t^.
if
Since
any, at
t^,
is
will associate
In this case
Otherwise the key of the edge
is
of cost no more than p(e) for
8
we
talcen to
with each
which the cost of the path
the current value of the parameter, this value will exist
more parameterized edges than
we
each
counterpart
a pivot path that consists of a path in
p(e) becomes equal to the cost of
edge.
T Thus
largest proper prefix of
u followed by the edge
a pivot path.
its
Any
Gx' and has at
as the corresponding path in
In order to find a canonical pivot path quickly,
edge
shortest
a pivot path. Let v denote the destination vertex of p.
proper prefix of p has the same number of parameterized edges as
in
its
call
be
if
and only
if
p(e) has
the value the key of the
infinity.
More
specifically,
let c{p)
denote the cost of a path p
G, and
in
—
paireimeterized edges on p, so tliat c{p)
Then
the key of
6e'{p) denote the
let
X6e'(p)
's
number
of
'h^ cost of a path p in Gx'-
e is
c{p{e))-c{t,)
^E'(p(e))-6E'(t.)
provided 6E'(p{e))
Since p(e)
time
if
>
^E'iU)' and infinity otherwise.
just i^ followed
is
we maintain,
for
by
e,
we can calculate edge keys
each path t^, the values
c(tu,)
in
constant
and 6E'{tw)-
When
a pivot occurs and the tree changes, we can find (and update) the vertices
for
which these values change by depth-first search from the end of the pivot
Furthermore, these values only change
path.
new
for a vertex
when
it
acquires a
shortest path, so the time to maintain these values over the course of the
algorithm
is
proportional to the
number of shortest path changes over the course
of the algorithm.
This gives us an implementation running
tree T, the values cf^^
by choosing the
If
we
find each
keys
is
)
and
minimum
O(n^tn) time
and perform each of the
(!>£'(<u,),
edge key
in
in
0(m) time
most n^ pivots
store the edge keys in a standard heap data structure, the time to
minimum
is
reduced to O(logn), so the total time to find
reduced to 0(n^ log n).
its
at
maintain the
to define a pivot path.
The time
minimum
to maintain the keys increases to
O(logn) per key change, but since the key of an edge
one of
—
is
changed only when
endpoints acquires a new path, the total number of edge key changes
during the course of the algorithm
is
at
9
most 2nm. Thus the
totad time spent
maintaining keys
is
is
0{nm\ogT}). This implementation of the algorithm, which
the implementation given by Karp and Orlin [K081], therefore runs
in
time
0{nm logn).
2.4
A
Vertex Keys
scribed above was given by
Fredman and Tarjan
Karp and Orlin
insert a key
minimum
is
0(1)
in
algorithm de-
1981, before the discovery by
of the Fibonacci heap data structure [FT87] in 1984.
advantage of the F-heap data structure
in the
The
that the time taken to decrease or
is
amortized sense [Tar85]. The time taken to find the
key or increase a key
there are graphs yielding
in
0(nm log n)-time
complete, but different, exposition of the
(9(logn)
is
Q{nm)
in
the amortized sense.
Although
key increases, so that storing the edge keys
an F-heap does not immediately give a
faister
algorithm, we can
still
use an
F-heap to our advantage.
To do
this,
we
associate with each vertex v a key which
the keys of the edges entering
v.
This
is
The minimum
vertex key
still
occurs, and a vertex acquires a
With
v.
the
this value
we
first
shortest path,
what
effect
When
Its cost
is
10
the
same
e.
a pivot
does that have
on the vertex keys? Recall that when a vertex acquires a new shortest path,
has more parameterized edges.
of
become equal
associate the edge
yields a canonical pivot path.
new
minimum
the value of the parameter at which
the cost of one of the potential pivot paths p(e) into v will
to the cost of the current path into
is
it
as the old path at the pivot
point, but
V changes
is
decreasing faster with the parameter.
depends on whether the
pivot paths into
t
change. Suppose the vertex does not acquire a
If
potential pivot into
t
If
sooner, so
if
new path
the vertex key changes,
a vertex acquires a
new
will
will
it
shortest path but
is
some
decreasing
overtake the current path
and none of the potential pivot
shortest path,
Thus
be overtaken as soon as the old
shortest
only decrease.
paths change, then the new shortest path, which
will not
new
changes, then the new potential pivot path
In this case, the
new
change. In this case the key
it
the vertex does not acquire a
it
faster than the old.
into
the key of a vertex
changes and how the potential
patli into v
path and none of the potential pivot paths into
remains the same.
How
is
decreasing in cost faster,
in this case
the key will increase.
For the remaining case, note that the number of parameterized edges on each
new
shortest path exceeds the
Thus
in this
number on the
same
case the key will stay the
determined the
minimum
if
old path by the
same amount.
the potential pivot paths which
value previously also change, and otherwise the key
will increase.
To summarize, a
the vertex.
vertex key
The algorithm
is
minimum
the
stores with each vertex key the edge
determines the value of the vertex key.
a pivot path from the
the values
c(<u,)
and
minimum
(!'£'(<„) for
maintain the vertex keys,
for
of the keys of the edges into
key,
each
As
whose key
before, the algorithm determines
computes the new tree T' and updates
,
if
which acquires a new shortest path. To
each vertex which acquires a
11
new
shortest path the
algorithm examines the keys of the edges coming into the vertex and takes the
new
vertex key to be the
minimum
key of each outgoing edge to see
at the other end,
and
if it
has,
(possibly increasing the key),
if it
it
and checks the
has decreased below the key of the vertex
updates that vertex key.
It
then continues
pivoting, as before.
The purpose
of this modification
fewer increase key operations
algorithm
is
in
now the algorithm needs
that
is
to
do
the worst case, so that the time taken by the
reduced by stormg the keys
an F-heap. In particular, we will see
in
next that the time taken to maintain keys, which dominates the time taken by
the algorithm,
is
reduced to
0{nm +
n^ logn), from
Running time
2.5
To bound
the time taken by the algorithm,
data structures takes 0(^n) time, plus
needs to be run to determine the
we
0(nm log n).
will associate
we note that the
0(nm)
time
initial tree.
each operation involved
in
if
initialization of the
a shortest path algorithm
To bound
the remaining time,
updating the data structures with
a shortest path change to some vertex, and then bound the total number of
shortest path changes during the course of the algorithm.
more
We
give a shghtly
detailed analysis them necessary, which will be useful in section
Let
m^
and j^ denote the degree of vertex
changes ("jumps") to
w
in
w and
the
number
the course of the algorithm.
of shortest path
Once pivoting
finding a pivot path takes amortized time O(logrj). At each pivot
12
5.
begins,
some vertex
changes path, so the time
is
for finding pivot
paths
is
0(logn ^^,
j^.)-
After a pivot
found, for each vertex which changes path the shortest path information for
updated, the edges into and out of the vertex are examined, the
the vertex
is
vertex key
may
decreased.
Thus each time w changes path the amortized time
data structures
be increased,
is
0(logn +
aind
)
may be
to maintain the
m^.). (Recall that the amortized times for increeise
key and decrease key operations
0(1)
the vertex keys of adjacent vertices
Thus the time taken by
the F-heap are, respectively, 0(\ogn) and
in
the algorithm after initialization
is
bounded by
a constant times
^
ju
+
77iu
log n
^
j„,
( 1
w
u
2^ ?7Ju +
<
n
<
2nr7j
+
log n
2_J jw
logn.
Ti-
(2)
+
Thus
the algorithm always runs
3
The Minimum Mean Cycle Problem
The mimmuTn mean
in
time 0{nin
cycle problem for a
n- logn).
graph with cycles
to find a directed
is
cycle in the graph that minimizes the average cost of the edges on the cycle.
The average edge
cost of such a cycle
is
lutions to this problem are needed in a
Goldberg and Tarjan [GT89] and
in
called the
mintmum
cycle
mean. So-
minimum-cost circulation algorithm of
a graph minimum-balancing algorithm of
Schneider and Schneider [SS87]. The problem has been studied by Karp [Kar78],
13
who gave
an
0(nm)-Ume dynamic programming
Orlin [A088],
is
the
algorithm, and by Ahuja and
who gave an 0{\/nm\ognC)-time
maximum
of the edge costs, which
(Here
scaling algorithm.
must be integers
for
C
the Ahuja-Orlin
algorithm to work correctly.)
As Karp and Orlin [K081] have observed, the minimum mean
lem can be solved using an algorithm
for the
cycle prob-
parametric shortest path problem.
Before we discuss how, we introduce the concept of a potential
Potentials are related to the dual variables arising
for
when path and
a graph.
flow prob-
lems are formulated as linear programs. They are also an inherent part of the
minimum
A
balance problem that we discuss
potential
is
in
the next section.
an assignment of real-valued weights to
llie
vertices of the
graph. Such a potential acts to change the edge costs of the graph, as follows.
The
cost of an edge e
subtracted from
it.
=
Thus
produces the graph G'
One
(u, i)
has the weight of u added to
potential
=
tt
(T, £,c'),
useful aspect of potentials
is
:
V —
«
9?
it
and the weight of r
acting on the graph
where c'(e
=
(u,v))
=
c(e)
+
G=
(
tt(u)
V,
E,
—
ir{v).
c)
that they do not change shortest paths or
costs of cycles.
It is
well
tential for
we
fix
there
known that
any graph with no negative-cost cycle, there
which the resulting graph has
a source vertex
is
for
s in the
no such vertex
in
graph
C
all
all
from which
all
vertices are reachable. (If
we introduce an
other vertices.
14
a po-
non-negative edge costs. Specifically,
the original graph,
vertex with zero-cost edges to
is
artificial
The minimum mean
source
cycle
is
unchanged by
to
e
V.
=
if e
Then
(u.v)-
lies
this alteration
known
the well
The
)
Let
be the cost of the shortest path from
7r(r)
<
inequality n(v)
G"
cost of edge e in
is
7r{u)
+
c(e) holds for every
on a shortest path, or on a zero-cost cycle, then equality holds
We
zero.
is
call
edge
Furthermore,
therefore non-negative.
above relation, so the transformed edge cost
s
in
the
a shortest path
ir
potential for G.
Using the notation of section
with A subtracted from
Cx
shortest paths in
all
with
2,
E =
edge costs, and
are well defined.
tt
for
that no edge
of
mean
in
est
G'
cost A* in
minimum mean
Thus
follows that
It
has cost
As shown
to solve the
path potential
earlier, if A'
It
G'
less
we then add A'
C
has a cycle
Gx'
oo, then
if
Gx-
we apply the
to all edge costs,
C
is
a
and the minimum cycle mean
Such a
cycle
problem
potentieil
is
we obtaun
with each edge of cost A*, and
than A'. Thus
minimum mean
for
^
follows that
minimum mean
G'. Since potentials do not change cycle
cycle in G,
G
Gx' to Ga-, we obtain a graph with a zero-cost
cycle and non-negative edge costs. If
the graph G'.
denote the graph
A* denote the largest A such that
let
has a zero-cost cycle, but no negative-cost cycle.
shortest path potential
Gx
£", let
it
in
costs,
G
is
suffices to
C
is
cycle
also a
A*.
obtain a short-
easily obtainable
from the
last
shortest path tree produced by the parametric shortest path eilgorithm run on
G
with
all
In this case the algorithm stops because
edges parameterized.
discovers a zero-cost cycle in Gx-
G. Thus the
minimum mean
,
cycle
which
in
problem
15
turn
is
is
a
minimum
it
meain cycle in
easily reduced to the parametric
shortest path problem.
As a
side note, the introduction of an artificial source vertex with zero cost
edges into
available.
all
An
the other vertices
initial
useful even
is
shortest path tree from the
by the zero cost edges, so there
an original source vertex
if
sirtificial
source vertex
is
is
given
no need to solve an arbitrary single source
is
shortest path problem. This variant corresponds to the sourceless parameterized
shortest path problem, where shortest paths independent of source into each
node
are
computed rather than
shortest paths from a particular source.
minimum mean
variation also applies to Karp's
simplifies
it
by removing an
initial
cycle algorithm [Kar78]
This
and
strongly connected components computation.
In practice, however, partitioning the graph into strongly connected
components
might reduce the solution time.
The Minimum Balance Problem
4
We
say a subset of the vertices of
among
edges entering the subset
leaving the subset.
graph
G=
(V,E,c)
IS
is
the
The mtntmum
mintmvm-balanced
same
as the
£
or
the
if
minimum
minimum
cost
cost
among edges
balance problem for a strongly connected
to determine a potential
of the vertices other than
said to
is
G
is
tt
such that,
minimum-balanced.
in
G', each subset
Such a potential
is
minimum-balance G. Schneider and Schneider introduced an equivalent
problem [SS87]
in
connection with matrix balancing, and they gave an O^n^m)-
16
time algorithm. Our algorithm,
runs
wliicli
time
in
0{nm +
n^logn), can be
viewed as a faster implementation of Schneider and Schneider's algorithm.
To
solve the
mminium
minimum mean
potential n and a
the graph.
In
balance problem, note that finding a shortest path
G"
C
cycle
a step towards minimum-balancing
is
C
each subset of vertices that
enters and leaves has edges
entering and leaving of cost exactly A', and no entering or leaving edge has cost
C
than A'. Consider contracting
less
to a single
new vertex
H
to be any function; otherwise
of cost no less then the
are
all
less
than A*, the
minimum
it
.
If
H
cycle
has only one vertex,
can be obtained recursively.
minimum
mean
cycle
mean
G'
TT
and
3.
H
.
Let
be a
/?
can be taken
The edges
which
essentially just
Consider extending the potential
is
of //"
turn no
in
/?
for
H
add the poten-
q
to the potential
for
defined by
{/3(i)
0{w)
The
in
of
deleting
of G.
To complete the minimum-balancing, we can
tials
C,
graph H.
self-loops but retaining multiple edges, to obtain the
potential that minimum-balances
v in
effect of
H
q on G"
becomes of
is
as follows.
u;
on C;
otherwise.
Each edge
in
G'
that corresponds to an edge
cost equal to the cost of the corresponding edge in
other edges, joining vertices on the cycle G, remain unchanged
a subset of the vertices
of cost A*, which are
is
entered and
left
by C,
it is
H^ The
.
in cost.
entered and
left
minimum. Otherwise, the edges entering and
Thus
if
by edges
leaving the
subset correspond to the edges entering and leaving the corresponding subset
17
of
and so the subset
vertices of //,
tlie
Thus the
is
correspondingly minimum-balanced.
+ a minimum-balances G.
potential n
summary, the minimum-beJancing algorithm repeatedly
In
tracts a
minimum meam
time the cycle
rent graph
is
finds
and con-
cycle until the graph contains only one vertex.
contracted, a shortest path potential
The minimum-balancing
potential
is
computed
is
Each
for the cur-
computed by adding together
the shortest path potentials, appropriately extended.
At
at
this point
we have reduced the minimum-balance problem
most n problems involving finding minimum mean
potentiails.
mean
By notmg
that Karp's
cycles
0(nm)-time algorithm
to a series of
and shortest path
for finding
minimum
cycles can be extended to yield shortest path potentials, Schneider
and
Schneider [SS87] obtained an 0(n-m)-time algorithm.
A
4.1
The
Hybrid Algorithm
successive graphs
computed by the above method are
minimum mean
modifying the parametric path algorithm to contract the
it
discovers and continue,
we obtain a
closely related.
will terminate,
(7a*
•
This
by the
is
and
E =
E'
.
Since
G
is
first iteration
G
with an
strongly connected, the algorithm
having produced A* and a tree 7* that
sufficient to obtain
cycle
faster algorithm.
Suppose that we run the parametric shortest path algorithm on
arbitr2Lry source s
By
is
a shortest path tree in
a shortest path potential for Gx-, as required
of the minimum-balance algorithm.
18
The minimum-balance algorithm would next
applying the shortest path potential
the discovered
minimum mean
cycle,
n,
adjust the edge costs of
First, to
it
and continue. Consider what happens
what extent can we maintain the shortest path
tree?
We
T
is
in
G'/C, G' contracted around C. By properties of the shortest path
a shortest path tree in Gx'- Since potentials preserve shortest paths,
is
C
also a shortest path tree in
=
We
GJ..
all
C.
follows that
It
T/C, the
zero cost edges in G'/C. Since
together with a path
like
a shortest path tree
in
T,
T/C
is
tree
C
T
potential,
C
or
T
are
contracted around the cycle
consists of a single edge not in
a tree in G'/C.
Thus T/C
is
T
a shortest path
G'/C.
Once
the shortest path tree
T/C
is
constructed, we can completely recom-
pute the secondary data structures, including
If,
would
that edge costs in G' are non-negative, and that edges on
of zero cost in
tree in
try
have a tree
that
C, has
we
if
through the adjustment and contraction.
T
we know
by
contract the resulting graph around
instead of stopping the parametric shortest path algorithm at this point,
to continue
G
c(tui)
and
^^'(^uj) for each vertex
the F-heap of vertex keys, and the
mapping of which edges have determined
We
are then ready to proceed with the induc-
which vertex keys,
in
0{m)
time.
tive step of the parametric shortest
pivot until the next
path algorithm, modifying the tree pivot by
minimum mean
cycle
19
is
found.
4.2
Termination and Running Time
The
algorillim continues pivoting and contracting,
cadculating the requisite
shortest path potentials at each contraction, until the graph contains only a
Note that the
single vertex.
initial
Thus every graph with
strongly connected.
cycle with a parameterized edge,
stop
is
graph and thus
by discovery of a
all
at least
subsequent graphs are
two vertices
will
have a
and so the only way a sequence of pivots can
minimum mean
cycle.
Since at most n contractions can take place, the time spent by the dgorithm
performing contractions and reinitializing data structures following a contraction
is
0{mn). The remaining time
is
spent pivoting from one tree to the next
between contractions The analysis of the parametric path algorithm bounding
the
number
each pivot
pivot
still
of pivots and the time spent maintaining the data structures after
in
terms of the number of path changes continues to apply here. Each
results in
some vertex acquiring a new path, and each operation main-
taining the data structures
To obtain
the
same worst
is
case
associated with a path change for
bound
(2),
it
suffices to
some
note that the
shortest path changes during the course of the algorithm
is still
vertex.
number
of
bounded by n
per vertex.
Consider, as the
tices in the
minimum
balance algorithm proceeds, the
number
of ver-
graph minus the number of pcirameterized edges on the shortest path
to a vertex w. Every lime the path changes as the result of a pivot, this quan-
tity decreases,
and contraction does not increase
20
it.
Furthermore, the qucintity
initially is at
at
most n and on termination
non-negative.
is
Thus
it
most n times, and the number of path changes associated with
is
decreased
u; is at
most
n.
5
Expected Running Times
Although there are graphs
minimum
shortest path and
that for many,
minimum
if
for
which the worst-case bounds
for
the parametric
balance algorithms are tight, one might suspect
not most, graphs the bounds are not tight. In the case of the
balance algorithm,
it
may be
that, for
most graphs, most vertices do
not acquire Q{n) new shortest paths throughout the course of the algorithm,
either because
when
new
a vertex acquires a
shortest path that path tends to be
substantially longer thain the old one, or because the contracted cycles tend to be
larger than constauit size.
algorithm
the
first
is
essentially the
Smce
the work done in the parametric shortest path
work done
in
minimum
badance algorithm before
contraction, one might expect that the work done by the parametric
shortest path algorithm would be even
To explore
this,
used for finding a
bound
the
less.
consider the behavior of the parametric path algorithm as
minimum
mecin cycle on
random graphs.
(1) as follows:
<
maxm^
^;,i, -l-logn^ju
21
We
can rewrite the
(-1
Figure
minimum mean
cycle
=
With high
rithm
is
n
Average number of shortest path changes per vertex when finding a
1:
so that
nl
it
probability, the
^
jw
f
max TTJ^ +
maximum
log n
degree of a
(3)
random graph
is
0(^ + logTj),
remains only to estimate the number of path changes when the algo-
run on random graphs.
To do
this,
we have run the
graphs of n nodes and
sourceless variant of the algorithm on
m edges with
each of the n(n
be present. For each n and m. we took ^ or
1)
edges equally likely to
fifty tri2ils,
whichever weis larger,
and averaged the number of path changes
in
average number of path changes per vertex
for the
22
—
random
each
trial.
Figure
1
shows the
parametric path algorithm
for finding a
The
minimum mean
results suggest that the expected
metric path algorithm
rithm yields a
0{n).
is
has worst
caise
We make
Lemma
1
Given
3^ >
is
0(m + n log n),
0{nm +
a
then the parametric path algo-
0{nTn
in
random graph
the following
uith n nodes
3— +
lemma
then clearly the
o{nm + n^
it
lemma and
and
log n
Z5
m
edges,
corollary.
the probabiliiy
no more than
Assume
holds.
that
log n).
m<
2n~^'*'^
^n^.
The
of graphs with n nodes and ni edges with a given vertex of degree d
/
2n
-
2
\
/
/
\
n{n
+
and the minimum balance algorithm
n^ log n) and expected time
of degree higher than
n.
for the para-
cycle algorithm with worst case time
argument precise
this
that no veritT
Proof. If
time
number of path changes
If this is true,
minimum mean
n^ log n) and expected time
number
cycle.
is
\
- l)-(2n-2)
9d
=
m
2n-2-d
9d-V
—
1
m—d
n{n-l)-(2n-2)-im-d)
d
2nm
—
d-^n(n
<
Thus
letting
q
=
3m
9d-i-T,
d(n -
[;22lJ
i)
>
TT3)
Jot d >
q, gj
<
^g^.^
<
pa2-(''-").
Thus
of graphs with a given vertex of degree greater than or equal to d
is
bounded by
t>d
23
the
number
= a+
k log n
Thus
the probabiUty that a given vertex
is
than 2rj"*, so the probability that some vertex
than 2n-*+'.
Q
Corollary 2
If the erpecitd
R
is
0(in
this degree or higher
is less
+
is
k log n or
0{n), then the expected
n log n).
be the running time of the algorithm on a random graph,
the quantity Ylw J^ (max^
m^ +
the graph have degree
than 3-^
changes.
is less
number of path changes
running time of the algorithm
Proof. Let
is
+
more
of degree a
Then bounds
EiR)
less
(2)
and
logn),
(3)
+
let
D
be the event that
and
2 logn,
and lemma
let
<
E{J
=
0(m + nlogn)f-^^^^ +
=
0(,n
=
0{m +
+
\ogn) \D)
be
vertices of
give
1
E{B) = Pr[D]E{B\D) + Pt[D]E{B\D)
O (— +
B
J be the number of path
<
X
all
let
+ -0{nin +
.logn)(^ +
7i-iogn)
l
l
n log n).
D
Figure 2 shows the ratio of the average time for our
cle
algorithm to the average time of Karp's 0(rjm)-time
algorithm, which runs
in
time
Q(nm)
minimum mean
minimum mean
cy-
cycle
for all graphs.
Although we did not implement the scaling minimum mean cycle algorithm
of
Ahuja and Orlin [A088], experience with
24
a related algorithm suggests that
(-1
»
nl
n
300
Figure
even
if
2;
Ratio of average time to average time for Karp's algorithm
the scaling algoritlim runs in expected time
0{n + m)
some reason-
for
able distribution of graphs, the constants involved would be larger than those
observed
We
for
our algorithm [Sch89].
also tested the
that the
number
minimum
balance algorithm. As figure 3 shows,
of contractions for a non-sparse
random graph
In the algorithm as described, the contraction step, which takes
is
0{m +
of the union-find data structure of Tarjan [Tar 79].
partial potentials
is
per
©(nm). The
vairiant
for zidding the
similarly reduced, so this modification should
25
about n/2.
nlogn) by using a
The time
appears
0(m) time
contraction, appears to be the bottleneck, giving a running time of
totjj time for contraction cem be reduced to
it
remove the
(-1
f
•
n)
n
Con tr action! /n
Figure
bottleneck.
As
3:
of yet
Average number of contractions per vertex
we have not estimated the expected running time of the
modified algorithm.
6
One
Final
Remarks
question not addressed by our parametric path algorithm
which the solution
is
is
the form in
produced. Recording the sequence of trees explicitly would
take space and time 6(n^)
in
for a particular value of the
the worst case of 0(n^) trees, and recovering a tree
parameter would require locating the value
sequence of intervals, which can be done easily
26
in
in
the
logn time. Alternatively, we
can store
eadi vertex the values of the parameter at which the parent changes
for
and which vertex becomes the parent
the space
for the
the
is
0{n') and any
tree can be recovered in
of times each vertex changes parent
probably an even better solution
a different note, a
in
the worst case
log n) time by searching
is
probably constant, so this
is
practice.
number of generalizations
The parametric path algorithm may be
sible.
0(n
in
parent of each node individually with a binary search. For most graphs,
number
On
Then
at each change.
of our algorithms are pos-
generalized to handle the case
when
the edge costs are
lar, if
the edge costs are concave functions of the parameter with derivative in
the set —A',
.
.
.
,
more general functions
of the parameter.
—1,0, then essentially the same algorithm works, provided the
functions are stored so that for each function we can
tell for
successive values
of the parameter what the current value and derivative are and
decrease in derivative will occur. For instance,
contain multi-edges, and each multi-edge
functions of constant derivative in [— A',
tive,
then pivots
In particu-
still
.
is
.
.
,
if
we allow the
given as a
list
1,0], in order of
when the next
initial
graph to
of edges with cost
decreasing deriva-
occur when the shortest path into a vertex changes, and
each such change decreases the derivative of the cost of the path into the vertex.
Essentially the
to each vertex
A'n^ trees
in
same
is
analysis applies to
in this case at
time
0{I\nm+
show that the number of path ch£mges
most An, and the algorithm produces
at
most
A'n^logn).
Surprisingly, the parametric path algorithm
27
may
also be generalized to allow
concave edge cost functions with positive derivative as
concave functions of the parameter with derivative
well. If the functions are
in the
ramge [—A',
..,
A'],
then
the same argument shows that essentially the same transition from one shortest
path
tree
tree to the next
is
more
still
difficult,
occurs.
In this case finding an initial shortest path
however, because an
which shortest paths are well defined
If all
value of the parameter for
not so easy to
is
come
by.
edge cost functions are non-negative at some point (say zero), then we
can start by finding a shortest path tree
parzimeter, generating trees
Then we can
zero cost.
in
leave
in
Go and proceed by
increasing the
sequence as before, until some cycle becomes of
return to
the parameter to generate the
We
initial
Go and proceed by decreasing the value
initial
of
part of the sequence of trees in reverse.
open the problem of finding an
initial
value of the parameter in the
general case.
We
also
might consider generalizing the minimum balance problem by allow-
ing the algorithm to proceed with arbitrary parameterizations.
the running time
still
holds, but in this case
of the problem the algorithm
is
we know
The
analysis of
of no natural interpretation
solving.
References
[A088] R. K. Ahuja and
ment and minimum
J.
cycle
B. Orlin,
"New
scaling algorithms for the assign-
mean problems". Working Paper
28
#
2019-88, Sloan
Institute of
Management
Cambridge,
MA,
Science, Massachusetts Institute of Technology,
1988.
[FT67] M. L. Fredman and R. E. Tarjan, "Fibonacci heaps and their uses
improved network optimization algorithms",
J.
in
Assoc. Comput. Macb. 34
(1987), 596-615.
[GT89] A. V. Goldberg and R. E. Tarjan, "Finding minimum-cost circulations
by canceling negative cycles",
[G085]
S.
C. Graves and
J.
B
J.
Assoc. Comput. Mach. 36 (1989), to appear.
Orlin,
"A minimum concave
work flow problem, with an application to
lot-sizing",
cost
dynamic
net-
Networks 15 (1985),
59-71.
[Kar78] R.
M
Karp, "A characterization of the
minimum
cycle
mean
in a di-
graph", Discrete Mathematics 23 (1978), 309-311.
[K081] R. M. Karp and
J.
B. Orlin, "Parametric shortest paths with an appli-
cation to cyclic staffing," Discrete Applied Mathematics 3 (1981), 37-45.
[OR85]
J.
B. Orlin and U. G. Rothblum,
"Computing optimal
scalings by para-
metric network algorithms", Mathematical Programming 32 (1985), 1-10.
[Sch89] N. Schlenker, personal communication,
Department of Computer
Sci-
ence, Princeton University, Princeton, NJ, 1989.
[SS87] H. Schneider and
M. H. Schneider, "Meix-balancing weighted directed
graphs", Department of Mathematics, University of Wisconsin, Madison,
29
Wisconsin; also Department of Mathematical Sciences, Johns Hopkins University, Baltimore,
MD,
[SS89] H. Schneider and
1987, revised 1989.
M
H. Schneider, 'Towers and Cycle Covers for
Max-
Balanced Graphs", Department of Mathematics, University of Wisconsin,
Madison, Wisconsin; also Department of Mathematical Sciences, Johns Hopkins University, Baltimore,
MD,
1989.
[Tar79] R. E. Tarjan, "Applications of path compression on balanced trees", J.
ACAf
[TEir85]
26 (1979), 690-715.
R. E. Tarjan,
"Amortized computational complexity", Siam
Disc. Metb. 6 (198.5), 306-318.
30
J.
Alg.
Date Due
j4^,
09^925
MIT
I
IBRARIFS
llllllliillllllllliilll
9080 00600 2288
3
Download