Tropical

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

PARAMETRIC SHORTEST-PATH ALGORITHMS

VIA TROPICAL GEOMETRY

MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

A b s t r ac t . We study parameterized versions of classical algorithms for comput-


ing shortest-path trees. This is most easily expressed in terms of tropical geometry.
Applications include shortest paths in traffic networks with variable link travel times.
arXiv:1904.01082v4 [math.CO] 7 Jul 2021

1. I n t ro d u c t i o n
One of the most basic classes of algorithmic problems in combinatorial optimization is the
computation of shortest paths for all pairs of nodes in a directed graph. The reader may
consult the monograph of Schrijver [Sch03] for a comprehensive survey. Here we study
parameterized versions where some of the arc weights are unspecified. It turns out that
standard tools such as the Floyd–Warshall algorithm [Sch03, §8.4] or Dijkstra’s algorithm
[Sch03, §7.2] admit interesting generalizations. While it is known that the shortest path
problem is connected to max-plus linear algebra and tropical geometry (see, e.g., [But10,
Chap. 4], [MS15, §5.2] and their references), this paper investigates how the geometric
underpinnings can be exploited algorithmically.
Dijkstra’s algorithm and its siblings are among the core tools used, e.g., in devices which
help a car driver to navigate a road network. These efficient methods allow for solving
the corresponding shortest path problems almost instantly, even on cheap hardware, and
even for fairly large networks. Methods from robust optimization have been used to take
some uncertainty about the link travel times into account, see, e.g., [YY98], [CDG19]
and the references there. Yet the situation for the network provider is quite different
from the perspective of the network user. One reason is that the provider’s goal does not
necessarily agree with the one of the user: While the individual driver might be interested
in short travel times, the traffic authorities of a metropolitan city might want to, e.g.,

2020 Mathematics Subject Classification. 14T90 (05C12, 68R10, 90B20, 90C31).


Key words and phrases. parametrized shortest paths; Dijkstra’s algorithm; traffic networks; tropical
geometry.
This research has been carried out in the framework of Matheon supported by Einstein Foundation
Berlin. Additional support by Institut Mittag-Leffler within the program “Tropical Geometry, Amoebas
and Polytopes” is gratefully acknowledged. M. Joswig has further been supported by the Deutsche
Forschungsgemeinschaft (DFG, German Research Foundation) under Germany’s Excellence Strategy
- The Berlin Mathematics Research Center MATH+ (EXC-2046/1, project ID 390685689); “Symbolic
Tools in Mathematics and their Application” (TRR 195, project-ID 286237555); “Facets of Complexity”
(GRK 2434). Furthermore, we are very grateful for the support by several colleagues. Ewgenij Gawrilow’s
work on the polymake project is crucial; here he implemented the parameterized Dijkstra algorithm.
Max Klimm was helpful in discussing the application to traffic. Georg Loho directed our attention to
the article [GGT89]. Two anonymous referees provided helpful suggestions to improve the exposition.
Thanks to everybody.
1
2 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

minimize the total amount of pollution. More importantly, the traffic authorities seek
to achieve a system optimum, whereas the driver cares for an individual objective; cf.
[JMSSM05]. Typically, in relevant cases it is next to impossible to even describe a system
optimum. Here we propose methods from tropical geometry to gain new insight. For
instance, this may be applied to assess the impact of local changes to a network a priori,
provided that the number of simultaneous modifications is not too high.
Tropical geometry is a thriving field, which combines algebraic and polyhedral geometry
with optimization; cf. [MS15]. The benefit is mutual: geometry gains algorithmic methods
through optimization, and topics in theoretical computer science and optimization may
be analyzed more deeply through geometric insight. Examples for the latter include
interpreting the decision problem MEAN-PAYOFF in terms of tropical linear programs
[AGG12], ordinary linear programs which exhibit a non-strongly polynomial behavior
for interior point methods [ABGJ18] or applications to multicriteria optimization [JL20].
Examples for the former abound, too; to name just one: the perfect matching problem,
classically solved by the Hungarian method [Sch03, §17.2], computes tropical determinants
[MS15, Prop. 1.2.5]. It is worth noting that our parameterized version of computing
shortest paths is of particular interest geometrically. Namely, this is related to enumerating
a class of convex polytopes known as polytropes or alcoved polytopes and has been studied,
e.g., by Tran [Tra17].
Our setup is the following. Let Γ be a directed graph with n nodes and m arcs.
Throughout we will assume that Γ has no parallel arcs. Additionally, each arc will be
equipped with a weight. Then the graph together with the weight function can be encoded
as an n×n-matrix where the coefficient at position (u, v) is the weight on the arc from u
to v. Necessarily we have m ≤ n2 , with equality if and only if Γ is a complete directed
graph with n loops. Since we will be interested in shortest path problems we consider
smaller weights as better, and this suggests to use ∞ to signal the absence of an arc. The
resulting matrix is a weighted adjacency matrix of Γ. This leaves the question: what are
the weights?
In the context of the shortest path problem a very general answer is the following. Let
(G, +) be a totally ordered abelian group such that ∞ is not an element of G. Then
G ∪ {∞}, equipped with “min” as the addition and “+” as the multiplication, is a semiring;
this is the (min, +)-semiring associated with G. Here ∞ is neutral with respect to the
addition and absorbing with respect to the multiplication. Via the usual rules for the
addition and the multiplication of matrices this entails a semiring structure on the set
(G ∪ {∞})n×n of n×n-matrices with coefficients in G ∪ {∞}. The classical shortest path
problem occurs when G is the additive group of the real numbers. We denote the extension
R ∪ {∞} of this group by T. However, it is interesting and useful to go one step beyond
by only requiring that G is a commutative semigroup equipped with a partial ordering,
which is not necessarily total. Then, in general, for a pair of nodes there are competing
shortest paths whose total weights are incomparable. We will see that basic algorithmic
ideas for solving shortest path problems still remain valid, with minor adjustments. The
case when G is the additive semigroup of tropical polynomials with real coefficients in a
fixed number of indeterminates is of particular interest to us.
To look at parameterized versions of shortest path problems is not a new idea. A first
paper which explores connections to polyhedral geometry is Fredman [Fre76]. Another
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 3

important precursor of our approach is a paper by Gallo, Grigoriadis and Tarjan [GGT89]
on a parametric version of the celebrated push–relabel method for computing maximum
flows by Goldberg and Tarjan [GT88]. Moreover, shortest path computations have been
considered in the context of robust optimization; cf. [BTEGN09] for a general reference.
For instance, Yu and Yang observed that in a digraph equipped with interval weights,
for given nodes s and t, it is NP-complete to decide whether there is a shortest s–t
path whose total weight stays below a certain threshold [YY98, Theorem 1]. Other
modern concepts in this area include online techniques (e.g., see [AAA+ 06]) as well as
robustness combined with randomization (e.g., see [MSS15]) and dynamic algorithms
(e.g., see [Ber16]). The s–t shortest path problems addressed in the above models are
relevant, e.g., for a single driver who wants to navigate her car through a road network
with uncertain link travel times. Here instead we are considering the all-pairs shortest
path problem, which amounts to taking the perspective of the provider of the network; cf.
Section 4 below for computational experiments on real-world data. These show that our
method is also practically useful, provided the output size is not too large.
Our paper is organized as follows. Section 2 starts out with a brief sketch on how to
generalize the classical algorithm of Floyd and Warshall to the scenario with parameterized
arc weights. Standard results on tropical hypersurfaces are invoked to reveal basic
structural insight into the shortest-path problem. The algorithmic core of this paper,
explained in Section 3, is a procedure for enumerating all parameterized shortest-path
trees to a fixed target node. This can be seen as a parameterized analog to Dijkstra’s
algorithm. We demonstrate that this algorithm is feasible in practice for few variable arc
weights. Our computational results are summarized in Sections 4 and 5.

2. Pa r a m e t e r i z i n g t h e F l oy d – Wa r s h a l l a l g o r i t h m
A standard method for computing all shortest paths between any pair of nodes in a directed
graph is the Floyd–Warshall algorithm. This is well-known to have a straightforward
interpretation in tropical arithmetic as follows. We will briefly sketch the method and
refer to [Sch03, §8.4] or [AHU75, Section 5.9] for details.
Let Γ be a directed graph on n nodes with weighted adjacency matrix D = (duv )u,v ∈
Tn×n . A naive algorithm for obtaining all-pairs shortest paths is to compute the (n−1)st
tropical power (I ⊕ D) (n−1) of the matrix I ⊕ D where I = D 0 is the tropical identity
matrix, with coefficients 0 on the diagonal and ∞ otherwise. Here we used “⊕” for the
tropical matrix addition, which is defined as the coefficientwise minimum, and “ ” for
the tropical matrix multiplication, i.e., the analog of classical matrix multiplication where
“min” and “+” replace the addition and the multiplication, respectively. In particular,
I ⊕ D is the weighted adjacency matrix of Γ with zeros along the diagonal if the graph
has no negative loops. For computing shortest paths the (n−1)st power is enough since
any shortest path, if it exists, takes at most n − 1 arcs. Each of the n − 2 multiplications
takes O(n3 ) time, resulting in a total cost of O(n4 ). We will not discuss clever strategies
for multiplying these matrices as we will beat this naive matrix multiplication approach
via (2) below. Unless there are negative cycles the coefficient of D (n−1) at position
(u, v) is the length of a shortest path from node u to v using exactly n − 1 arcs, and the
coefficient of (I ⊕ D) (n−1) at position (u, v) is the length of a shortest path from node
u to v. Moreover, a negative cycle exists if and only if a coefficient on the diagonal of
4 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

(I ⊕ D) n or D is negative. Formally, the solution to the all-pairs shortest path problem


can be written as
(1) D∗ = I ⊕ D ⊕ D 2
⊕ ··· ⊕ D (n−1)
⊕ ··· ,
which converges to (I ⊕ D) (n−1) = I ⊕ · · · ⊕ D (n−1) if and only if there is no negative
cycle. The matrix D∗ is called the Kleene star of D; cf. Butkovič [But10, §1.6.2.1].
Floyd and Warshall’s algorithm reduces the complexity of computing D∗ to O(n3 ) via
dynamic programming. The key ingredient is the weight of a shortest path from u to v
with all intermediate nodes restricted to the set {1, 2, . . . , r}, which is

0
 if r = 0 and u = v
(2) d(r)
uv =
duv   if r = 0 and u 6= v
min d(r−1) , d(r−1) + d(r−1)

if r ≥ 1 .
uv ur rv

That is, in the nontrivial step of the computation we check if going through the new
node r gives an advantage.
(r) 
We set D(r) = duv u,v . By applying the formula (2) recursively, the Floyd–Warshall
algorithm computes D(n) in O(n3 ) time. The trick is that, with D(r−1) known explicitly,
(r)
the computation of a single coefficient duv requires only constant time. Note that this
method is also suitable for detecting negative cycles by checking the diagonal of the
result. A negative cycle exists if and only if some diagonal coefficient of D(n) is negative.
Otherwise D(n) = (I ⊕ D) (n−1) = D∗ . In general, D(r) is distinct from any tropical
power (I ⊕ D) k whenever 1 ≤ r < n − 1.
Remark 1. For computing all-pairs shortest path in a dense graph with arbitrary weights
there is no algorithm known that beats the O(n3 ) complexity bound; see [Sch03, §8.6].
Yet Floyd and Warshall’s algorithm was improved by Fredman in [Fre76] when the edge
weights are restricted to be nonnegative. Fredman’s bound is based on the reduction of
computing the Kleene star D∗ to tropical matrix multiplication; see [AHU75, Theorem 5.7
and Corollary 2]. Moreover, he subdivides
√ the √ matrix multiplication into the multiplication
of smaller block matrices of sizes n × n and n × n, respectively. In combination with a
clever search method this leads to a bound of O(n5/2 ) comparisons. Further, this approach
leads to an algorithm of complexity O(n3 log log(n)/ log(n)2 ) by Han and Takaoka [HT16];
see [Sch03, §7.5] for a general overview of all-shortest paths with nonnegative weights and
[HT16] for more recent developments.
Our first observation is that the same ideas can be applied in the presence of variable arc
weights. To this end we consider a weighted adjacency matrix where each coefficient is a
multivariate polynomial whose coefficients lie in the (min, +)-semiring T = R∪{∞}. These
polynomials again form a semiring, and thus, via the usual addition and multiplication,
the set of n×n-matrices with coefficients in T[x1 , . . . , xk ] is a semiring, too.
Formally, a k-variate tropical polynomial, f ∈ T[x1 , . . . , xk ], with finite support set
S ⊂ Zk , is a map which assigns each exponent a ∈ S a coefficient γa ∈ R. This gives rise
to the evaluation function f (t1 , . . . , tk ) = min{γa + a1 t1 + · · · + ak tk | a ∈ S} which sends
t ∈ Rk to a real number. That function is piecewise linear, continuous and concave; cf.
[MS15, §1.1]. For each a ∈ S the set {t ∈ Rk | f (t) = γa + a1 t1 + · · · + ak tk } is a convex
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 5

y y

2
4 + 2x 3+x 4
x+1

x x
y 9
2 +y
2+x+y

6 + 2y

F i g u r e 1 . Two generic tropical plane curves. Each region is marked


with the term at which the minimum is attained. Left: tropical line defined
by min(2, 1 + x, y). Right: tropical quadric defined by min(4, 3 + x, 4 +
2x, 2 + x + y, 6 + 2y, 92 + y).

polyhedron. That set is a region of f if that polyhedron is of maximal dimension k. The


regions are the domains of linearity of f , and they form a polyhedral subdivision of Rk ;
cf. Figure 1. The tropical hypersurface T (f ) is the locus where at least two terms of f
are minimal; i.e., T (f ) “lies between” pairs of regions.
Now, if D is a matrix with coefficients in T[x1 , . . . , xk ], then each coefficient of D
defines a tropical hypersurface and a polyhedral subdivision of Rk . The maximal cells
of the common refinement of the polyhedral subdivision taken over all coefficients of D
are the regions of D. Each region of D is the intersection of the regions of the tropical
hypersurfaces corresponding to some set of coefficients of D.

Observation 2. The solution to the all-pairs shortest paths problem of a directed


graph with n nodes and weighted adjacency matrix D ∈ T[x1 , . . . , xk ] is a polyhedral
decomposition of Rk induced by up to n2 tropical hypersurfaces corresponding to the
nonconstant coefficients of D (n−1) . On each polyhedral cell the lengths of all shortest
paths are linear functions in the k parameters.

By multiplying the nonconstant tropical polynomials of a matrix D ∈ T[x1 , . . . , xk ]n×n


we obtain one tropical polynomial which yields the tropical hypersurface induced by D,
and this is denoted by T (D). The regions of T (D) are precisely the regions of D.

Example 3. The weighted adjacency matrix


 
0 ∞ ∞ 1
 1 0 ∞ ∞
(3) D =   y 1 0 ∞ ,

∞ x 1 0
6 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

whose coefficients lie in the semiring T[x, y] of bivariate tropical polynomials, defines a
directed graph, Γ, on four nodes. The third tropical power of D = I ⊕ D reads
 
min(2 + x, 2 + y, 0) min(1 + x, 3) 2 1
3 1 min(2 + x, 0) 3 2
D =  .
 
min(y, 2) min(1 + x + y, 1) min(2 + y, 0) min(1 + y, 3) 
min(1 + x, 1 + y, 3) min(x, 2) 1 min(2 + x, 2 + y, 0)
Ten among the 16 coefficients duv3 are nonconstant. Three of the corresponding tropical
polynomials are linear and generic, i.e., they have three terms: d1,13 = d4,43 = min(2 + x, 2 +
y, 0) and d4,13 = min(1+x, 1+y, 3). Six coefficients are linear but degenerate. Among these
we have the equalities d1,23 = min(1 + x, 3) = 1 + d4,23 and d3,43 = min(1 + y, 3) = 1 + d3,13 .
Only the coefficient d3,23 = min(1 + x + y, 1) is nonlinear; it is a (degenerate) tropical
polynomial of degree two. In Figure 2 the resulting two nondegenerate and four degenerate
tropical lines are marked by circles at their apices. Those lie at infinity in the degenerate
cases. The tropical quadric degenerates to an ordinary line, which is marked by two
squares. We obtain an arrangement of 2 + 4 + 1 = 7 tropical hypersurfaces. Their product
is the tropical hypersurface T (D 3 ) induced by D 3 , up to multiplicities, and it has 15
regions.
Now we want to extract information about shortest paths from this geometric data.
The diagonal of D 3 reveals that there are no negative cycles unless x < −2 or y < −2.
All coefficients are finite, and thus Γ is strongly connected. The feasible domain is the set
(x, y) ∈ R2 x ≥ −2, y ≥ −2 ,


where shortest paths between any two nodes exist. It is subdivided into seven regions,
four bounded and three unbounded ones. Eight of the 15 regions of D 3 are infeasible.
Comparing tropical polynomials f, g ∈ T[x1 , . . . , xk ] as real functions we set
(4) f ≤ g : ⇐⇒ f (z) ≤ g(z) for all z ∈ Tk .
This defines a partial ordering. It is easy to see that f and g are comparable if and only
if f = ∞, g = ∞ or f (z) = c + g(z) for some constant c ∈ R.
Consider a matrix D ∈ T[x1 , . . . , xk ]n×n . We say that D has separated variables if each
indeterminate occurs, with multiplicity one, in the weight of at most one arc. In this
way there is no dependence among the weights for distinct arcs. Then each coefficient
of D involves a constant plus a sum of indeterminates. We may reduce the number of
variables by substituting the sum of indeterminates by a single variable. Thus we assume
that the entries of D are linear tropical polynomials. It then follows that k ≤ m ≤ n2 .
This property is satisfied by the matrix (3) in Example 3.
Theorem 4. Let D ∈ T[x1 , . . . , xk ]n×n be the weighted adjacency matrix of a directed
graph on n nodes with separated variables. Then, between any pair of nodes, there are
at most 2k pairwise incomparable shortest paths. Moreover, the Kleene star D∗ , which
encodes all parameterized shortest paths, can be computed in O(k · 2k · n3 ) time, if it exists.
Proof. We consider the case without negative cycles, i.e., cycles whose total weight is
comparable to and strictly less than zero. Then there is at least one shortest path between
any two nodes; for convenience here we take paths of weight ∞ into account. In each
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 7

d3,23 y

0 1+x 2 1 0 3 2 1
   
 1 0 3 2 1 0 3 2
3  2 1 0 3 2 1 0 3
1+x x 1 0 3 2 1 0

d3,13 2 d4,13
0 1+x 2 1
 
 1 0 3 2 
 y 1 0 1 + y
1+x x 1 0

3 2 
 y 1+x+y 0 1+y 

 y
 1

1+x 2 1

1 0

1+y x

0 1+x
0 3 2 1
 
 1 0 3 2 

1
0
0  y 1 0 1+y  x
x
0

1 0
0 1+y 
3 2 
2 1
1+y 2 1 0
1+x
0
 1


−1

0 1+x 2 1
 
 1 0 3 2 
 y 1+x+y 0 1+y 
1+y x 1 0
d3,33 −2 d1,13

−3

−3 −2 −1 0 1 2 3

d2,23 d1,23 d3,23

F i g u r e 2 . Decomposition of R2 into the 15 regions of the Kleene star


D 3 from Example 3. These are induced by an arrangement of six tropical
lines and one tropical quadric. On each of the seven feasible regions the
lengths of the shortest paths are linear functions in x and y. The eight
infeasible regions are shaded.

shortest path each arc occurs at most once unless the total weight of the path is ∞. By
our assumption this means that the total weight is equal to λ + xi1 + · · · + xi` for some
λ ∈ T and xi1 + · · · + xi` is a multilinear tropical monomial, i.e., each indeterminate
occurs with multiplicity zero or one. There are 2k distinct multilinear monomials, and
hence this bounds the number of incomparable shortest paths between any two nodes.
To obtain our complexity result we use the Floyd–Warshall algorithm with the compu-
(r)
tation of the coefficients duv via (2) as the key step. In our parameterized scenario each
coefficient of D (r−1) is a multilinear tropical polynomial. The tropical multiplication,
i.e., ordinary sum, of two multilinear monomials takes linear time in the number of
indeterminates, which is at most k. Each coefficient of D(r−1) has at most 2k terms by
8 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

(r)
our bound on the number of incomparable shortest paths. We infer that computing duv
takes not more than O(k · 2k ) time, and this yields our claim. 

If the coefficients of D ∈ T[x1 , . . . , xk ]n×n are linear tropical polynomials, then each
coefficient in D (n−1) is a tropical polynomial of degree at most n − 1, and thus the
degree of the tropical hypersurface T (D (n−1) ) does not exceed n2 (n − 1), which is of
order O(n3 ). This occurs, e.g., when D has separated variables.
Corollary 5. With the same conditions as in Theorem 4, and if k is considered a fixed
constant, all parameterized shortest paths can be computed in O(n3 ) time, if they exist.
Remark 6. The special case when all the arc weights are variable is of particular interest
to tropical geometry. This is equivalent to enumerating a class of convex polytopes known
as polytropes; cf. Tran [Tra17]. The precise connection to our results is beyond the scope
of this article.

3. A pa r a m e t e r i z e d a n a l o g t o D i j k s t r a’ s a l g o r i t h m
The Floyd-Warshall algorithm considered in the previous section is very useful to get a
conceptual overview of the shortest-path problem. The Kleene star D∗ = (I ⊕ D) (n−1) =
D(n) itself does not directly provide us with the information about all shortest paths
for all choices of parameters simultaneously. Instead this is only determined by the
polyhedral decomposition of the parameter space Rk into the regions of D∗ , induced
by the tropical hypersurface T (D∗ ). In this section we propose a method, inspired by
Dijkstra’s algorithm, to find the regions of D∗ , given D.
Dijkstra’s algorithm is the main method for computing shortest paths used in applica-
tions; cf. [Sch03, §7.2]. It computes a shortest-path tree directed toward a fixed node. In
this setting it is common to assume that all weights are nonnegative, and this is what we
will do here.
Let Γ be a directed graph with n nodes, without parallel arcs, and weighted adjacency
matrix D = (duv )u,v ∈ T[x1 , . . . , xk ]n×n . Working with nonnegative weights means
that we consider the feasible region of the matrix D within the positive orthant. The
nonnegativity assumption entails that a shortest path from any node to any other node is
well defined or, equivalently, the Kleene star D∗ exists. Since we do not assume that Γ is
strongly connected, we allow for “shortest paths” of infinite length.
Motivated by an application to traffic networks (cf. Section 4) we choose the following
setup. Each arc (u, v) in Γ is equipped with a weight interval [λuv , µuv ] subject to
0 ≤ λuv ≤ µuv ≤ ∞ .
If µuv = ∞ then we abuse the notation [λuv , µuv ] for the ray { x ∈ R | x ≥ λuv }. Similarly,
if λuv = µuv = ∞, then [∞, ∞] is the empty set which signals the absence of an arc. In
Section 4 below, the weight interval will describe a range of possible travel times along a
link in a traffic network. We explicitly allow for the case λuv = µuv , i.e., the arc (u, v)
may be equipped with a constant weight. Assuming that there are precisely k arcs with
nonconstant weights, we can identify those arcs with the variables, for which we also use
the notation xuv . Conversely, we also write “λ(xi )” for the given lower bound on xi and
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 9

“µ(xi )” for the given upper bound. Setting the coefficients of D to


(
xuv if λuv < µuv
duv =
λuv otherwise ,
we arrive at the case of separated variables. So Theorem 4 applies, but here we restrict
the feasible domain to the polyhedron [λ(x1 ), µ(x1 )] × · · · × [λ(xk ), µ(xk )] in Rk . That
polyhedron is compact, if and only if all upper bounds are finite.
From now on we will compare two tropical polynomials f, g ∈ T[x1 , . . . , xk ] with respect
to this polyhedron, i.e., we let f ≤ g if f (z) ≤ g(z) for all z ∈ [λ(x1 ), µ(x1 )] × · · · ×
[λ(xk ), µ(xk )]. Whenever the tropical polynomials f and g are sums of the arc weights on
paths with separated variables, then checking f ≤ g can be done with a single evaluation
of each of the polynomials: that is, in this case f ≤ g if and only if f (µ) ≤ g(λ) where λ
and µ are the minimum and the maximum, respectively, taken over all variable bounds
involved. If not further specified then λ(xi ) = 0 and µ(xi ) = ∞.
A compact way to represent the set of shortest paths to a single target is a shortest-
path tree. A shortest-path tree is the result of Dijkstra’s algorithm when all weights are
constant. Motivated by [Tar83, Theorem 7.3], we extend the notion of shortest-path trees
to the partial ordering ≤. We call a spanning tree T with all edges directed toward the
target node t a shortest-path tree if, for every arc (v, w),
(5) dvw + pw 6< pv ,
where pv is the length of the path from v to t in the tree T . Often we will denote such a
directed spanning tree as a pair (T, p) in order to stress that all subsequent complexity
bounds require the function p to be given explicitly. A direct consequence of (5) is:
Observation 7. A given directed spanning tree (T, p) has n−1 arcs out of the m arcs of Γ.
Thus there are at most m − n + 1 arcs (u, v) such that dvw + pw and pv are incomparable.
In particular, it can be tested in O(k · m) time whether a directed spanning tree is a
shortest-path tree.
The solution to computing shortest-path trees toward the node t in a directed graph with
n nodes and weighted adjacency matrix D ∈ T[x1 , . . . , xk ] is a polyhedral decomposition
S of Rk induced by up to n − 1 tropical hypersurfaces corresponding to the nonconstant
coefficients in the column labeled t in the Kleene star D∗ . Note that all diagonal entries
are zero as there are no negative cycles. On each polyhedral cell the lengths of all shortest
paths are linear functions in the k parameters. Each such cell is a union of cells of the
subdivision induced by the tropical hypersurface T (D∗ ).
Lemma 8. Every shortest-path tree (T, p) gives rise to a polyhedral cell in the decomposi-
tion S. That cell is described by the inequalities
(6) pv ≤ dvw + pw for all arcs (v, w) .
Every region of D arises in this way.
Proof. The inequalities (6) are linear, and thus they define a polyhedron P = P (T ). For
every nonnegative point x ∈ Tk Dijkstra’s algorithm produces a shortest-path tree, Tx ,
and we have x ∈ P (Tx ). As a consequence these polyhedra cover the feasible domain.
10 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

c d
2 3
b
5 4
x

a
5≤2+x 3+x≤4

F i g u r e 3 . The shortest-path tree in the directed graph of Example 9


that does not correspond to a feasible region.

(n)
The terms pv and dvw + pw appear in the entry dv,t of the Kleene star D∗ . Thus each
cell of S is either contained in P , or they are disjoint. On the other hand, if x ∈ P (T )
then every path in T has to be a shortest path after substitution of the variables. In other
(n)
words, if q is a term of dv,t which is minimal for x then pv and q evaluate to the same
value at x. This implies that P is contained in a cell of S. We conclude that P ∈ S, and
every region is of that form. 
Clearly, it is enough to take only those arcs into account for which pv is incomparable
to dvw + pw . The following example shows that a shortest-path tree T may yield a lower
dimensional cell or even the empty set.
Example 9. Consider the directed graph on four nodes shown in Figure 3 whose weights
lie in the semiring T[x] of univariate tropical polynomials. The Kleene star of its weighted
adjacency matrix is
 
0 ∞ ∞ ∞
x 0 ∞ ∞
D∗ = 

(7) min(2 + x, 5) 2 0 ∞ .

min(3 + x, 4) 3 ∞ 0
The first column of D∗ yields four shortest-path trees with node a as the target. The four
corresponding systems of inequalities read
x≤1, 1≤x≤3, 3≤x, x ≤ 1 and 3 ≤ x ;
where the final system is infeasible. That is, there are only three regions.

Remark 10. In Example 9 the single arc of variable weight is the only outgoing arc of the
node b and ends at the target node a. More general, suppose G is a simple directed graph
with n nodes and k arcs of variable weight such that they all end at the target node t and
these arcs are the only outgoing arcs of the corresponding nodes. Every node (other than
the target node) with an outgoing arc of constant weight has up to k + 1 incomparable
paths to the target. This leads to at most (k + 1)n−k−1 shortest-path trees. However,
it can be shown that the number of regions of the graph G does not exceed n−1

k . As
the n − k − 1 nodes with at most k + 1 incomparable shortest path to t correspond to
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 11

n − k − 1 tropical linear polynomialsin k variables. For which it is known that their


common refinement has at most n−1 k maximal cells. As illustrated in Figure 3, there
are shortest-path trees that do not correspond to feasible regions.
Remark 11. Finding the dimension of a polyhedral cell given in terms of linear inequalities
can be reduced to solving linear programs; cf. [GLS93, Theorem 6.5.5].
Our aim is it to enumerate all shortest-path trees, and hence, via solving linear programs,
all maximal dimensional polyhedral regions. We will discuss our choices and other options
at the end of this section. We consider the graph G = G(D) whose nodes are all shortest-
path trees, and which has an edge between two nodes if the corresponding trees share
n − 2 common edges, i.e., there is exactly one node u with two outgoing edges, and the
two paths from u to the target t are incomparable.
Remark 12. The graph G(D) contains the dual graph of the polyhedral subdivision S
as a connected subgraph.
A graph traversal enumerates all nodes in the connected component of some first node.
This is the core of our approach, which employs the following two procedures.
Algorithm A (Find an initial shortest-path tree). Set each unknown xi to its minimal
value λi . Run Dijkstra’s algorithm to obtain a shortest-path tree, with fixed arc weights,
for the target node t. Let T be this shortest-path tree, equipped with the original weights.
For each node u this yields a parameterized distance pTu ∈ T[x1 , . . . , xk ] from u to t in T .
That initial tree T is a first node of the graph G(D).
Algorithm B (Traversing G(D)). We will maintain a queue, Q, of pairs of trees and
parameterized distances. That queue is initialized with a single shortest-path tree (and
pairs of parameterized distances to the target node t) obtained from Algorithm A.
While Q is nonempty, pick and remove from Q the next tree T , together with the
parameterized distances pTv from v to t. For every arc (v, w), compare pTv with dvw + pTw .
If they are incomparable add pTv ≤ dvw + pTw to a system of inequalities associated with
T , and replace the outgoing arc of v by (v, w) to obtain a new tree T 0 . Compute the new
0
parameterized distances pT , and check whether T 0 is a shortest-path tree. In that case
and if additionally T 0 has not been considered before, add T 0 to Q. Output the triplet of
the tree T , the distance function pT and the system of inequalities describing the region
of T , when there is no arc left to compare.
Remark 13. Algorithm B is a breadth first search on G(D); cf. [Tar83, Chapter 1].
The order in which the traversal is organized is not particularly relevant. Similarly, the
initial shortest-path tree constructed in Algorithm A could be replaced by any other
shortest-path tree with a non-empty feasible region of parameters.
Let us now determine bounds on the number σ = σ(D, t) of shortest-path trees with
target t and weighted adjacency matrix D. That is also the number of nodes in G(D)
and a crucial parameter for the complexity of the Algorithm B. We will use two further
definitions in our analysis. We call a variable active in a shortest-path tree when it occurs
in the weight of one of its arcs. Moreover, an adjacency matrix is generic if no two
collections of arcs yield the same sum of weights, and this applies to a variable weight
12 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

xi by taking the minimal value λi and the maximal value µi into account. Formally, we
consider the set of weights

W := { dvw | v, w ∈ [n], dvw constant} ∪ { λi | i ∈ [k]} ∪ { µi | i ∈ [k], µi < ∞}

whose elements we require to be pairwise distinct such that, moreover, any two subsets of
W (independent of their cardinalities) yield distinct weight sums. For instance, genericity
entails that the shortest-path tree of any connected subgraph (with fixed target) is unique,
if it involves only arcs of constant weight. This will simplify the proofs, but it does not
restrict the applicability of our results; see Remark 21 below.
The proof of our main result uses the analysis of a special class of directed graphs,
where it matters how the arcs with variable weights are distributed. For this we have a
technical lemma, which we split into two parts, to increase the readability.

Lemma 14. Let D ∈ T[x1 , . . . , xk ]n×n be the weighted adjacency matrix of a directed
graph with n = 2k + 1 nodes with the following arcs and weights: Each node u ∈ [k] has
a unique outgoing arc, to the node u + k, with variable weight du,u+k = xu . Each node
v ∈ {k + 1, . . . , 2k} has arcs to the nodes w ∈ [k] ∪ {n} of arbitrary positive constant
weight dv,w ∈ R>0 ∪ {∞}. There are no other arcs, and there exists at least one path from
each node to n whose weight has a finite constant term. If D is generic, then σ(D, n) ≤ k!.

Note that there are no arcs between any two nodes in [k] nor between any two nodes
in {k + 1, . . . , 2k}. The arcs with variable weights form a matching.

Proof. Without loss of generality, and since D is generic, we may assume that k + 1 is
the unique node for which the weight dk+1,n is minimal among all weight of arcs ending
at n. Then the shortest path from 1 to n (via k + 1) is unique, as dk+1,n < dk+u,n implies
dk+1,n < dk+1,u + xu + dk+u,n for u ∈ {2, . . . , k} and xu ≥ 0. Every shortest-path tree T
partitions the set of nodes into two parts, namely those whose shortest path to n passes
through 1 and the others. Since u for u ∈ [k] has a unique outgoing arc, the nodes u and
u + k are always in the same part. In this way, the partition of the nodes induced by T is
described by a partition of [k] into two parts. Let T1 be the subtree of T that includes
the node 1 and all nodes u, u + k with a shortest path through 1; this is a shortest-path
tree (on that subset of nodes) directed to 1. Similarly, the subtree T 0 of all the other
nodes except for k + 1 is a shortest-path tree directed to n. Combining the arcs in T1
and T 0 with the arc (k + 1, n) yields the arcs of T ; as k + 1 is fixed the trees T1 and T 0
determine T .
For a directed graph that satisfies the assumptions of the current Lemma 14, let σk
denote the maximal number of shortest-path trees directed to the fixed target node n.
Now the two subgraphs on nodes of the partition induced by the tree T are of the same
shape as in our assumption. So there is some index j such that σj counts the shortest-path
trees in T1 (with target node 1), and σk−j−1 counts the shortest-path trees in T 0 (with
target node n). There are k−1

j ways to choose a subset of {2, . . . , k} of size j and hence
we arrive at
k−1  
X k−1
σk ≤ · σj · σk−j−1 .
j
j=0
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 13

2
1 x1 6 1 4
8
1 4 x4

5 x5 2 x2 7 5 9

3 11
1 x3 12
3 8

F i g u r e 4 . The directed graph from Example 16.

Pk−1 k−1

We have σ0 = 0! = σ1 = 1! = 1. Finally, induction on k gives σk ≤ k! = j=0 j j!(k −
j − 1)!. 
Setting ` = 0 in the next result is precisely Lemma 14, which we just proved. Before
we enter the precise formulation we consider two examples.
Example 15. The bound of Lemma 14 is tight. It is attained, e.g., if the arcs (u + k, v)
have weight 2u−1 + u − 2v − v for all u > v with u, v ∈ [k], the arcs (u + k, n) have weight
2u−1 + u − 1 for u ∈ [k], and there are no other arcs of constant weight.
Example 16. Figure 4 illustrates the conditions of Lemma 17 below, where k = 3 and
` = 2. It shows a directed graph with 9 = 2 · k + ` + 1 nodes, 5 = k + ` variables, and ten
arcs of constant weight. While the weighted adjacency matrix is not generic, the paths to
t have distinct weights. The graph in Figure 4 has 30 ≤ 120 = (k + `)! ≤ 125 = (k + `)k
shortest-path trees directed to the node n = 9. If the two nodes 4 and 5 are deleted with
all their in- and outgoing arcs and nodes are relabeled one gets an example of a graph
with parameters k = 3 and ` = 0. This new graph has 6 = 3! shortest-path trees directed
to 9. This number agrees with the bound given in Lemma 17. However, that bound is
not tight for large values of `.

Lemma 17. Let D ∈ T[x1 , . . . , xk+` ]n×n be the weighted adjacency matrix of a directed
graph with n = 2k + ` + 1 nodes with the following arcs and weights: Each node u ∈ [k]
has a unique outgoing arc, to the node u + k + `, with variable weight du,u+k+` = xu . Each
node u ∈ {k + 1, . . . , k + `} has a unique outgoing arc, to some node w < u or w > k + `,
with variable weight du,w = xu . Each node v ∈ {k + ` + 1, . . . , 2k + `} has arcs to the
nodes w ∈ [k + `] ∪ {n} of arbitrary positive constant weight dv,w ∈ R>0 ∪ {∞}. There
are no other arcs, and there exists at least one path from each node to n whose weight has
a finite constant term. If D is generic, then σ(D, n) ≤ min{(k + `)!, (k + `)k }.
Proof. We first prove that σ(D, n) ≤ (k + `)k . The successor of each node in [k + `] is
unique. In a shortest-path tree there is exactly one arc from each of the remaining k
nodes (excluding the target node) to one of the nodes in [k + `] ∪ {n} which is not the
predecessor. Thus the number of shortest-path trees satisfies σ(D, n) ≤ (k + `)k .
14 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

Now we show that σ(D, n) ≤ (k + `)!. Let us relabel the node n = 2k + ` + 1 by


n = 2(k + `) + 1, and add ` new nodes {2k + ` + 1, . . . , 2k + 2`}. Furthermore, we replace
each arc (u, v) with u ∈ {k + 1, . . . , k + `} by the two arcs (u, u + k + `) and (u + k + `, v)
of weight xu and weight εu respectively, for some small positive number εu > 0 such that
the resulting graph has a generic adjacency matrix. This process does not change the
number of shortest-path trees. However, this new graph meets the conditions of Lemma 14
with k + ` variables. Thus σ(D, n) ≤ (k + `)!. 
We consider the function Φ : N × N → N defined as
k  
X k
Φ(n, k) := (i + 1)n−i−1 .
i
i=0

For instance, we have Φ(n, 0) = 1 and Φ(n, 1) = 1 + 2n−2 . Clearly,


k  
X k  1 k
Φ(n, k) ≤ (k + 1)n−i−1 = (k + 1)n−1 · 1 + < e · (k + 1)n−1 ,
i k+1
i=0
where e is Euler’s constant.
Theorem 18. Let D ∈ T[x1 , . . . , xk ]n×n be the weighted adjacency matrix of a directed
graph with n nodes and m arcs. Suppose that D is generic and has separated variables
(with lower and upper bounds), and let t ∈ [n] be some node. Further, let σ = σ(D, t) be
the number of shortest-path trees with target node t. Then
  
n−2 m
σ ≤ min Φ(n, k), n , ,
n−1
and the graph traversal Algorithm B computes the shortest-path trees together with an
inequality description for each region of D∗ in O(k ·m2 ·σ +n2 ) time. The space complexity
is bounded by O(k · (n + m) · σ).
Proof. Since each spanning tree in a graph with n nodes has only n − 1 edges, there are
m
at most n−1 (shortest-path) trees in the graph defined by D.
Next let us discuss the extremal case k = n2 − n. Then we have as many variables as
possible, say, with weight intervals [0, ∞], and the graph defined by D is K
e n , the complete
directed graph on n nodes. In this case any two arcs and paths are incomparable, and thus
all labeled spanning trees of the undirected graph are produced as output. By Cayley’s
formula the complete undirected graph Kn has precisely nn−2 labeled spanning trees.
Note that fixing the target node t in an undirected spanning tree amounts to picking t as
the root and directing all edges toward it. Since increasing the number of variables cannot
decrease the number of shortest-path trees we obtain the second inequality σ ≤ nn−2 .
Now we will look into the general case. We want to count the number of shortest-path
trees toward t with exactly i active variables. Fix a set of i variables, which amounts to
fixing a set, A, of i arcs, as we have separated variables. Furthermore, let ` denote the
number of arcs in A whose end point has an outgoing arc in A or is the target node t.
Now pick some directed spanning tree, T , with target t that includes the i arcs in A and
no other arc with variable weight. Note that such a tree might not exist, whence we may
overestimate the number of shortest-path trees.
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 15

In the next step we contract the arcs in T with constant weight whose start point has
no incoming arc of variable weight. Here we add the weight of a contracted arc (u, v) to
the weight of each in-arc of u. In this way we keep exactly i − ` of the arcs with constant
weight. We arrive at a directed tree with 2i − ` + 1 nodes and 2i − ` = (i − `) + i arcs.
By construction, this tree is a subgraph of a graph like in Lemma 17 with parameters
k = i − ` and `. In fact, the parameter i − ` overestimates what is called k in Lemma 17
whenever two arcs with with variable weight point to the same node and its outgoing arc
is constant. At any rate, there are at most ii−` of these trees.
Undoing the contraction of the constant arcs we obtain shortest-path trees with at most
n − 2i + ` − 1 additional nodes. From any of these additional nodes a shortest path to t
either is of constant length or uses an arc with variable weight. In the latter case there
are i choices for the first arc taken with variable weight while constant shortest paths are
unique as D is generic. Hence there are at most (i + 1)n−2i+`−1 choices and in total at
most (i + 1)n−2i+`−1 · ii−` shortest-path trees for a fixed set of i active variables. Clearly
n−2i+`−1 i−` n−i−1 k

i ≤ i + 1 and hence (i + 1) ·i ≤ (i + 1) . Since there are i such sets we
conclude that the total number of shortest-path trees satisfies also the final inequality
σ ≤ Φ(n, k).
Now let us estimate the complexity of Algorithm B in terms of the number of variables k,
the number of nodes n, the number of arcs m and the number of shortest-path trees σ.
The initial step is to compute a shortest-path tree, T , with Algorithm A. This means,
first, to create an n×n adjacency matrix with constant weights, second, to apply Dijkstra’s
algorithm, and, third, to find the inequality description of the feasible region for T . That
takes O(n2 ) for the first two steps and O(k · n) for the third, adding up to O(k · n + n2 ).
The queue Q of the Algorithm B treats every shortest-path tree at most once. It follows
from Observation 7 that such a tree T has at most m arcs that lead to an inequality of the
region of T , and hence at most m potential neighbors in G(D). It takes O(k · n) to update
0
the distances pT and O(k · m) to check whether T 0 is a shortest-path tree. Thus in total
the time complexity of the Algorithm B is at most O(k · n + n2 + k · m · σ · (n + m)) =
O(n2 + k · m2 · σ), as n − 1 ≤ m.
In terms of space complexity the Algorithm B is a typical breadth-first search: the
dominating contribution comes from the queue Q, whose length is bounded by σ. Each
entry of the queue contains a tree, on n nodes, the distances to the target, and the list of
constraints of the corresponding region. The distance function has n entries, and the at
most m edges give the linear constraint in the k indeterminates. We infer that the total
space complexity is of order at most O(k · (n + m) · σ), in the unit cost model. 

Corollary 19. Let D be a generic weighted adjacency matrix with separated variables.
Algorithm B enumerates all shortest-path trees of D to a fixed node, together with their
distance functions and inequality description of their polyhedral cell, that are path-connected
in G(D) to a shortest-path tree of a feasible region. In particular, it enumerates a shortest-
path tree for every feasible region.

Proof. Every node of G(D) is a shortest-path tree. Thus, by definition of an edge in G(D)
every neighbor that is unseen will be added to the queue of Algorithm B and hence be
visited and enumerated. The shortest-path tree computed in Algorithm A corresponds to
16 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

1 3 5

2 4 6

F i g u r e 5 . The directed graph from Example 20. Variable arcs are bold,
non-tree arcs are dashed.

a region, and by Remark 12, every shortest-path tree of a region is in the same connected
component. 
Example 20. To illustrate the generic case in the proof of Theorem 18 we consider the
directed graph with seven nodes shown in Figure 5, where we omit the weights. We use the
same notation as in the proof. The arcs (1, 3), (2, 4), (3, 5), (4, 6), (5, t) and (6, t) form the
directed spanning tree T . The set of arcs with active variables is A = {(2, 4), (3, 5), (5, t)},
i.e., i = 3. The only arc with a nonactive variable is (4, 5). The constant arcs (1, 3) and
(6, t) are contracted, and ` = 2. The weight of (6, t) is added to both, (3, 6) and (4, 6)
which now point to the target node; the weight of (1, 3) is irrelevant, since the in-degree
of 1 is zero.
Remark 21. The assumption concerning the genericity of the arc weights in Theorem 18
is not essential. In fact, via picking a fixed total ordering of the arcs one can break ties
between two candidates of shortest paths by comparing them lexicographically. This
technique is known as “symbolic perturbation” and implemented in our polymake code;
see also Section 4.
Remark 22. Theorem 18 could also be proved without Lemma 17. However, the current
proof additionally shows that the bound given is not tight whenever ` > 0. Moreover,
that argument also allows to estimate the number of feasible regions in Proposition 24.
Remark 23. Two variables cannot simultaneously be active if they share the same initial
vertex. This situation occurs, e.g., when k ≥ n; hence Φ(k, n) overestimates the number
of shortest-path trees in that range. The function Φ(k, n) is the sum over the maximal
number of shortest-path trees with i ≤ k active variables. These maxima cannot be
attained simultaneously if k ≥ 2; thus Φ(k, n) overestimates the number of shortest-path
trees also for k ≥ 2. Clearly, our bound is tight for (directed) trees, the complete directed
graph K e n on n nodes with k = n2 − n variables, and on graphs with k ≤ 1 variables.

In general, many trees enumerated by Algorithm B and counted in Theorem 18 will


correspond to regions which are infeasible. So it is desirable to independently bound the
number of feasible regions.
Proposition 24. Let D be the weighted adjacency matrix of a directed graph on n nodes.
Then the number of feasible regions, which are induced by the shortest paths to a fixed
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 17

target node, is at most


k   k  
X k (n − 1)! X k
(8) ≤ (n − 1)i = nk .
i (n − i − 1)! i
i=0 i=0

Proof. There is a shortest-path tree for every feasible region. Thus we may estimate the
number of feasible regions by counting shortest-path trees. Again we do this by fixing a set
of i active variables and take only those trees into account that include the corresponding
arcs and no other arcs of variable weight. Now there are two types of tropical hypersurfaces
arising from such a tree. Those which correspond to nodes whose outgoing arc weight is
one of the active variables, there are i of those, and those nodes whose outgoing arcs are
of constant weight of which exist n − i − 1. The common refinement of the first once has at
most i! many regions as this is the bound of shortest-path trees in Lemma 17. The latter
hypersurfaces result from nodes which have at most i + 1 incomparable shortest paths
to the target. Moreover, the total weights of those paths are linear, up to substitution
of variables. Hence, the common refinement of these hypersurfaces has at most n−1 i
regions; see also Remark 10. There are ki ways to choose i active variables hence the

total number of feasible regions is at most
k     k  
X k n−1 X k (n − 1)!
· i! · = .
i i i (n − i − 1)!
i=0 i=0

The number of feasible regions in Proposition 24 is much smaller than the bound of
the number of trees in Theorem 18. This raises the question why we let Algorithm B
take such a “detour”. For instance, we could employ the parametric Floyd–Warshall
algorithm, which runs in O(k · 2k n3 ) time and thus is faster than Algorithm B. However,
from Floyd–Warshall we only obtain the Kleene star, an n×n matrix with entries in
T[x1 , . . . , xk ], from which it is rather expensive to extract all shortest-path trees or regions.
Conceptually we could compute the decomposition into regions by a dual convex hull
computation in Rk+1 but this requires at least as many as (8) linear constraints. In
Section 4 we will see that Algorithm B can easily compute instances for k = 10 and n
in the range of hundreds or even thousands. Convex hull computations of that size are
entirely out of question; cf. [AGH+ 17] for a recent survey on the subject. Thus a much
superior strategy is to first enumerate the trees and then to filter for the feasible regions
by linear programming. As an additional advantage the latter step can be parallelized
trivially.
Yet, from a practical point of view, it may also be useful to combine the parameterized
Floyd-Warshall algorithm with Algorithm B. The two methods are quite different and
thus exhibit different advantages. Imagine a car driver with a very long drive to her
destination city. The traffic situation in the city depends on the time when she reaches
the city. Therefore, the driver’s navigation system might evaluate the parameterized
Kleene-star with up-to-date data whenever there is a branching point. This would lead to
a complete choice of reasonable routes at any given time. Other scenarios are conceivable,
where the Kleene star is used to compute a description by inequalities of a feasible region
in O(k · n2 ) time from a generic feasible point. Such information could be valuable for
18 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

network operators or providers. While investigations of this kind look promising, in the
next section we restrict our attention to several instances of one scenario.

4. C o m p u tat i o n s
We report on extensive computational experiments with polymake [GJ00].

4.1. Implementation. In the following we collect some details on implementing Algo-


rithm B. The genericity of the matrix D can be achieved by a symbolic perturbation
of the arc weights. Choosing an ordering on all arcs induces a (lexicographic) ordering
on arbitrary sets of edges. In particular, this gives a total ordering on the set of all
(shortest-path) trees. We may pick the ordering on the arcs in such a way that the
shortest-path tree produced by Algorithm A is minimal. The lexicographic ordering on
the shortest-path trees allows to traverse G(D) without a lookup table or cache. This can
be interpreted in terms of Dijkstra variants based on “labeling” and “scanning”; cf. [Tar83,
§7.1]. See also, e.g., [GKMS08] for a dynamic routing algorithm employing that idea.
For maximal speed it is relevant to organize the trees and especially the queue of trees to
be processed by means of suitable data structures. Most importantly, there is an improved
version of Dijkstra’s algorithm by Fredman and Tarjan [FT87] based on Fibonacci-Heaps.
The latter leads to a complexity of O(m + n log(n)) in the unparameterized setting; see
also [Sch03, §7.4].
An optimized variant of Algorithm B has been implemented by Ewgenij Gawrilow in
the polymake software system [GJ00]. This implementation uses dynamic programming
and backtracking to traverse the graph implicitly. The code is available as an extension to
polymake, version 4.1; see https://polymake.org/extensions/polytropes.

4.2. Real-world traffic data. To show that our methods are feasible in practice we tried
the parameterized Dijkstra Algorithm B on real-world data sets from the Transportation
Networks repository [Trate]. Before we explain our experimental setup we wish to spend a
few words on those traffic data. We focus on the files with the extension tntp. Each file
encodes a directed graph which comes from a road network and additional information
about the travel time along the arcs. For every arc (u, v) the link travel time, depending
on the flow x, is the quantity
lt(u,v) (x) = ft(u,v) · 1 + B( capx )pow ,

(9)
(u,v)

where ft(u,v) is the free flow travel time, B is the bias, cap(u,v) is the capacity and pow is
the power. This formula was devised by the Bureau of Public Roads (BPR), a predecessor
organization of the Federal Highway Administration (FHWA) of the United States. The
tntp-files contain all these parameters for every arc. In our data we found B = 1 and
pow = 4 throughout; these parameters are used to model certain nonlinearities extracted
from empirical data. Usually there are also some zones, i.e., nodes which no traffic can
go through. For a more comprehensive discussion of the data and the parameters we
recommend the web site [Trate] and the references given there.
All timings in our experiments were taken on Intel(R) Core(TM) i7-3930K CPU @
3.20GHz, turbo 3.73 GHz (BogoMIPS: 6399.75) with openSUSE 42.3 (Linux 4.4.132-53).
The memory consumption did not exceed 200 MB.
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 19

106
102

101 104
time (s)

time (s)
100 102

10−1 100

10−2 10−2
101 102 103 104 105 106 103 105 107 109
# solutions # solutions

F i g u r e 6 . Data set “Berlin-Mitte-Center”. polymake running times


versus number of solutions, both log-scaled. Left: p = 0.05 yielding 25
variable weights. Right: p = 0.08 yielding 42 variable weights (computation
for one node aborted after a week).

4.3. One graph, all nodes. In the first scenario we considered the “Berlin-Mitte-Center”
data set from [Trate], which was originally provided by Jahn et al. [JMSSM05]. This
network describes a directed graph with 398 nodes and 871 arcs. The first 36 nodes are
zones. Since no traffic can go through a zone, we removed them, along with the incident
arcs. The remaining network has 362 nodes and 583 arcs.
From this data file we created random instances in the following way. As an additional
parameter we fix some probability p ≥ 0. Each arc independently receives a variable
weight with probability p. For the constant weights we take the free flow travel times,
which are always positive. Each variable weight is constrained to an interval from the free
flow travel time to the link travel time (9) for a flow value set to a random proportion
of the link capacity. That is, e.g., for p = 0 we get a usual weighted digraph where the
arc weights are the free flow travel times. For positive p we get some variable weights
which are intervals [ft(u,v) , lt(u,v) (r · cap(u,v) )] with 0 ≤ r ≤ 1, and 0 < r < 1 almost surely.
This is the scenario discussed in Section 3. The complexity of Algorithm B is primarily
controlled by the number of arcs with variable arc weights. Moreover, for a fixed graph
that complexity is proportional to the size of the output, i.e., the number of combinatorial
types of shortest-path trees. So, in order to obtain a computationally feasible setup, the
probability p cannot be too high. That is, on most of our arcs the flow is set to zero
(and the arc weight is ft(u,v) ), while on a small percentage of the arcs the flow is between
zero and some fraction of the capacity (and the arc weight is a variable with lower bound
ft(u,v) ). In this way our experiment models the situation early in the morning, when most
roads are still empty and the first few vehicles start to enter the traffic.
For the first experiment, by setting the probability to p = 0.05, we obtained 25 arcs
with variable weights, and this is about 4.3% of the total number of arcs. The second
experiment is similar, with p = 0.08 and 42 variable weights (about 7% of the arcs). For
both instances we applied the parameterized Dijkstra algorithm to all the 362 nodes.
Figure 6 has an overview of the timings.
20 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

F i g u r e 7 . Data set “Berlin-Mitte-Center” with p = 0.05 resulting in


25 variable weights. Arcs with variable weights are red; their line width
is proportional to the difference between maximum and minimum travel
times. Node sizes proportional to log log(#solutions). Layout obtained
via neato from the Graphviz package [EGH+ te].

For p = 0.05 most computations could be completed by polymake within less than a
second. The largest one took nearly 100 seconds with more than one million combinatorial
types of shortest-path trees. This network is displayed in Figure 7.
The case where p = 0.08 is quite different. For some nodes the computations took
several hours, and one computation was aborted after more than one week. By and large
this shows the limits of our approach. Note that not only the total number of variable arc
weights matter but also how clustered they are near the target node; this can also be seen
in Figure 7 in the smaller case p = 0.05. The largest complete computations produced
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 21

Ta b l e 1 . The maximum and average performance on the the data from


[Trate]. Ten runs each with k = 10 variables. The bar–whisker plots show
logarithmic performance.

Maximum Average
n m
# Sol. Sol./sec # Sol. Sol./sec
Anaheim 378 796 32 35199.5 5.4 6189.77
Barcelona 910 1957 5184 12548.4 524.7 1997.03
Berlin-Center 12116 19724 36480 417772.0 4622.4 68506.98
Berlin-Mitte-Center 362 583 144 55907.3 19.9 11500.81
Berlin-MPFC 877 1410 4590 59761.6 524.4 23118.37
Berlin-Pberg-Center 314 451 4 113636.0 1.6 40322.51
Berlin-Tiergarten 335 560 8 14670.6 4.5 7865.83
ChicagoRegional 11192 35436 192 5094.8 36.8 981.14
ChicagoSketch 546 2176 512 202605.0 103.7 41586.64
Berlin-Fhain-Center 201 339 90 120967.0 12.7 42332.21
Hessen-Asym 4415 6184 1 172.6 1.0 167.29
Philadelphia 11864 30779 24 713.0 11.2 328.49
Sydney 29849 67381 12 150.6 9.2 114.05
Terrassa-Asym 1554 2953 32 11790.8 4.1 1522.54
Winnipeg-Asym 903 1923 4 2423.2 1.6 978.36
Winnipeg 905 2284 160 3530.2 18.8 1436.35

Anaheim
3.09 4.55
Barcelona
2.47 2.78 4.10
Berlin-Center
2.41 3.76 5.62
Berlin-Mitte-Center
3.26 3.55 4.75
Berlin-MPFC
3.09 4.34 4.78
Berlin-Pberg-Center
3.35 3.94 5.06
Berlin-Tiergarten
3.25 3.80 4.17
ChicagoRegional
2.03 2.48 3.71
ChicagoSketch
3.18 3.56 5.31
Berlin-Fhain-Center
3.48 4.08 5.08
Hessen-Asym
2.22
Philadelphia
1.77 2.38 2.85
Sydney
1.69 2.18
Terrassa-Asym
2.58 4.07
Winnipeg-Asym
2.78 3.38
Winnipeg
2.61 2.99 3.55
22 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

several billions of shortest-path trees. The diagrams in Figure 6, which are log-scaled in
both directions, reflect the output-sensitivity of Algorithm B as predicted by Theorem 18.

4.4. Many graphs, some nodes. In the second scenario we looked at all the data sets
(_net.tntp files) from [Trate]. These were preprocessed as in the first scenario, i.e., by
removing the zones. This lead to excluding the three smallest data sets Austin, Braess,
and SiouxFalls because too few arcs remained. As a result we processed 16 directed
graphs. The most demanding one is Berlin-Center with n = 12116 nodes and m = 19724
arcs.
This time we fixed the number of variable arcs a priori to k = 10, and this set of
arcs was chosen uniformly at random. On each variable arc (u, v) we took the interval
[ft(u,v) , 2 · ft(u,v) ]. We picked a node uniformly at random as the root, which the shortest-
path trees are directed to; and this experiment was repeated ten times per instance.
Qualitatively the parameterized Dijkstra Algorithm B behaves exactly as in the first
scenario in Section 4.3. The running times vary considerably, but the predominant
factor is the total number of solutions. This is consistent with our theoretical analysis
of the running time from Theorem 18. And this also agrees with what we observed
experimentally in Figure 6 for the first scenario. Instead of the timings itself, Table 1
gives basic statistical information about the performance, which we define as the number
of solutions per second. Since we also list the (maximum and the average of) the number
of solutions the actual running times can be deduced if necessary. Here we have fewer
variables (but several much larger graphs), and thus the fluctuations are larger. Again
this is no surprise; compare the left and the right diagram in Figure 6. A more detailed
idea about the entire statistics can be derived from the bar–whisker plots below Table 1.
For the decadic logarithm of the performance it shows the minimum, the 25% percentile,
the median, the 75% percentile and the maximum per data set.
We think that even the fairly small number of ten random samples per graph suffices
to show that the overall behavior of Algorithm B and its polymake implementation is
well captured by the comprehensive analysis in Section 4.3.

5. C o n c l u d i n g r e m a r k s
In Section 4 we provided experimental evidence to show that our approach is viable in
practice, provided that the output size is moderate. Indeed, we are not aware of any other
limiting factor. For instance, other models of randomly picking variable link travel times
significantly change the running times only as far as the total number of shortest-path
trees is affected. This is supported by Table 1 which exhibits that the running time per
solution found, on a logarithmic scale, stays in a narrow range over a wide selection of
rather different networks. That is to say, the diagram to the right of Figure 6 captures
our algorithm’s asymptotic behavior on sufficiently large networks rather well.
Our assumption on separated variables models parametric shortest-path problems with
the maximal degree of independence among the parameters. It is conceivable that our
approach can be extended to more elaborate settings, but at the price of a greater technical
overhead in the analysis.
PARAMETRIC SHORTEST-PATH ALGORITHMS VIA TROPICAL GEOMETRY 23

References
[AAA+ 06] Noga Alon, Baruch Awerbuch, Yossi Azar, Niv Buchbinder, and Joseph Naor. A general
approach to online network optimization problems. ACM Trans. Algorithms, 2(4):640–660,
2006.
[ABGJ18] Xavier Allamigeon, Pascal Benchimol, Stéphane Gaubert, and Michael Joswig. Log-barrier
interior point methods are not strongly polynomial. SIAM J. Appl. Algebra Geom.,
2(1):140–178, 2018.
[AGG12] Marianne Akian, Stéphane Gaubert, and Alexander Guterman. Tropical polyhedra are
equivalent to mean payoff games. Internat. J. Algebra Comput., 22(1):1250001, 43, 2012.
[AGH+ 17] Benjamin Assarf, Ewgenij Gawrilow, Katrin Herr, Michael Joswig, Benjamin Lorenz, Andreas
Paffenholz, and Thomas Rehn. Computing convex hulls and counting integer points with
polymake. Math. Program. Comput., 9(1):1–38, 2017.
[AHU75] Alfred V. Aho, John E. Hopcroft, and Jeffrey D. Ullman. The design and analysis of com-
puter algorithms. Addison-Wesley Publishing Co., Reading, Mass.-London-Amsterdam, 1975.
Second printing, Addison-Wesley Series in Computer Science and Information Processing.
[Ber16] Aaron Bernstein. Maintaining shortest paths under deletions in weighted directed graphs.
SIAM J. Comput., 45(2):548–574, 2016.
[BTEGN09] Aharon Ben-Tal, Laurent El Ghaoui, and Arkadi Nemirovski. Robust optimization. Princeton
Series in Applied Mathematics. Princeton University Press, Princeton, NJ, 2009.
[But10] Peter Butkovič. Max-linear systems: theory and algorithms. Springer Monographs in
Mathematics. Springer-Verlag London, Ltd., London, 2010.
[CDG19] André Chassein, Trivikram Dokka, and Marc Goerigk. Algorithms and uncertainty sets for
data-driven robust shortest path problems. European J. Oper. Res., 274(2):671–686, 2019.
[EGH+ te] John Ellson, Emden Gansner, Yifan Hu, Erwin Janssen, Stephen North, et al. www.
graphviz.org, no date.
[Fre76] Michael L. Fredman. New bounds on the complexity of the shortest path problem. SIAM J.
Comput., 5(1):83–89, 1976.
[FT87] Michael L. Fredman and Robert Endre Tarjan. Fibonacci heaps and their uses in improved
network optimization algorithms. J. Assoc. Comput. Mach., 34(3):596–615, 1987.
[GGT89] Giorgio Gallo, Michael D. Grigoriadis, and Robert E. Tarjan. A fast parametric maximum
flow algorithm and applications. SIAM J. Comput., 18(1):30–55, 1989.
[GJ00] Ewgenij Gawrilow and Michael Joswig. polymake: a framework for analyzing convex
polytopes. In Polytopes—combinatorics and computation (Oberwolfach, 1997), volume 29 of
DMV Sem., pages 43–73. Birkhäuser, Basel, 2000.
[GKMS08] Ewgenij Gawrilow, Ekkehard Köhler, Rolf H. Möhring, and Björn Stenzel. Dynamic routing
of automated guided vehicles in real-time. In Mathematics—key technology for the future,
pages 165–177. Springer, Berlin, 2008.
[GLS93] Martin Grötschel, László Lovász, and Alexander Schrijver. Geometric algorithms and
combinatorial optimization, volume 2 of Algorithms and Combinatorics. Springer-Verlag,
Berlin, second edition, 1993.
[GT88] Andrew V. Goldberg and Robert E. Tarjan. A new approach to the maximum-flow problem.
J. Assoc. Comput. Mach., 35(4):921–940, 1988.
[HT16] Yijie Han and Tadao Takaoka. An O(n3 log log n/ log2 n) time algorithm for all pairs shortest
paths. J. Discrete Algorithms, 38/41:9–19, 2016.
[JL20] Michael Joswig and Georg Loho. Monomial tropical cones for multicriteria optimization.
SIAM J. Discrete Math., 34(2):1172–1191, 2020.
[JMSSM05] Olaf Jahn, Rolf H. Möhring, Andreas S. Schulz, and Nicolás E. Stier-Moses. System-
optimal routing of traffic flows with user constraints in networks with congestion. Oper.
Res., 53(4):600–616, 2005.
[MS15] Diane Maclagan and Bernd Sturmfels. Introduction to tropical geometry, volume 161 of
Graduate Studies in Mathematics. American Mathematical Society, Providence, RI, 2015.
24 MICHAEL JOSWIG AND BENJAMIN SCHRÖTER

[MSS15] Jannik Matuschke, Martin Skutella, and José Soto. Robust randomized matchings. In
Proceedings of the 26th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA
2015), pages 1904–1915. ACM, 2015.
[Sch03] Alexander Schrijver. Combinatorial optimization. Polyhedra and efficiency. Vol. A,
volume 24 of Algorithms and Combinatorics. Springer-Verlag, Berlin, 2003. Paths, flows,
matchings, Chapters 1–38.
[Tar83] Robert Endre Tarjan. Data structures and network algorithms, volume 44 of CBMS-NSF
Regional Conference Series in Applied Mathematics. Society for Industrial and Applied
Mathematics (SIAM), Philadelphia, PA, 1983.
[Tra17] Ngoc Mai Tran. Enumerating polytropes. J. Combin. Theory Ser. A, 151:1–22, 2017.
[Trate] Transportation Networks for Research Core Team. Transportation networks for research.
https://github.com/bstabler/TransportationNetworks, no date. Accessed Au-
gust 14, 2018.
[YY98] Gang Yu and Jian Yang. On the robust shortest path problem. Computers Ops. Res.,
25(6):457–468, 1998.

(Michael Joswig) T e c h n i s c h e U n i v e r s i tät B e r l i n , C h a i r o f D i s c r e t e M at h e m at -


i c s / G e o m e t ry , a n d M P I M i S , L e i p z i g , G e r m a n y
Email address: joswig@math.tu-berlin.de

(Benjamin Schröter) D e pa rt m e n t o f M at h e m at i c s , K T H Roya l I n s t i t u t e o f T e c h -


nology, Stockholm, Sweden
Email address: schrot@kth.se

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy