Contraction of Timetable Networks With Realistic Transfers: Geisberger@kit - Edu
Contraction of Timetable Networks With Realistic Transfers: Geisberger@kit - Edu
Realistic Transfers
Robert Geisberger
Karlsruhe Institute of Technology (KIT), 76128 Karlsruhe, Germany
[email protected]
Abstract. We contribute a fast routing algorithm for timetable net-
works with realistic transfer times. In this setting, our algorithm is the
rst one that successfully applies precomputation based on node contrac-
tion: gradually removing nodes from the graph and adding shortcuts to
preserve shortest paths. This reduces query times to 0.5 ms with prepro-
cessing times below 4 minutes on all tested instances, even on continental
networks with 30 000 stations. We achieve this by an improved contrac-
tion algorithm and by using a station graph model. Every node in our
graph has a one-to-one correspondence to a station and every edge has
an assigned collection of connections. Also, our graph model does not
require parallel edges.
Key words: route planning; public transit; algorithm engineering
1 Introduction
Route planning is one of the showpieces of algorithm engineering. Many hierar-
chical route planning algorithms have been developed over the past years and are
very successful on static road networks (overview in [1]). Recently, Contraction
Hierarchies (CH) [2] provided a particularly simple approach with fast prepro-
cessing and query times. CH is solely based on the concept of node contraction:
removing unimportant nodes and adding shortcuts to preserve shortest path
distances. One year later, time-dependent CH (TCH) [3] was published and works
well for time-dependent road networks, but completely fails for timetable net-
works of public transportation systems. In this paper, we show how to adapt CH
successfully to timetable networks with realistic transfers, i. e. minimum trans-
fer times. The positive outcome is partly due to our station graph model, where
each station is a single node and no parallel edges between stations are neces-
sary. Additionally, we change the contraction algorithm signicantly and deal
with special cases of timetable networks, e. g. loops.
Partially supported by DFG grant SA 933/5-1, and the Concept for the Future of
Karlsruhe Institute of Technology within the framework of the German Excellence
Initiative.
Related Work
Public transportation networks have always been time-dependent, i. e. travel
times depend on the availability of trains, buses or other vehicles. That makes
them naturally harder than road networks, where simple models can be indepen-
dent of the travel time and still achieve good results. There are two intensively
studied models for modeling timetable information: the time-expanded [4,5,6],
and the so-called time-dependent model
1
[7,8,9,10]. Both models answer queries
by applying some shortest-path algorithm to a suitably constructed graph. In
the time-expanded model, each node corresponds to a specic time event (depar-
ture or arrival), and each edge has a constant travel time. In the time-dependent
model, each node corresponds to a station, and the costs on an edge are as-
signed depending on the time in which the particular edge will be used by the
shortest-path algorithm.
To model more realistic transfers in the time-dependent model, [7] propose
to model each platform as a separate station and add walking links between
them. [11] propose a similar extension for constant and variable transfer and
describe it in more detail. Basically, the stations are expanded to a train-route
graph where no one-to-one correspondence between nodes and stations exists
anymore. A train route is the maximal subset of trains that follow the exact
same route, at possibly dierent times and do not overtake each other. Each
train route has its own node at each station. Those are interconnected within a
station with the given transfer times. This results in a signicant blowup in the
number of nodes and creates a lot of redundancy information that is collected
during a query. Recently, [12,13] independently proposed a model that is similar
to ours. They call it the station graph model and mainly use it to compute all
Pareto-optimal paths in a fully realistic scenario. For unication, we will give
our model the same name although there are some important dierences in the
details. The most signicant dierences are that (1) they require parallel edges,
one for each train route and (2) their query algorithm computes connections per
incoming edge instead per node. Their improvement over the time-dependent
model was mainly that they compare all connections at a station and remove
dominated ones.
Speed-up techniques are very successful when it comes to routing in time-
dependent road networks, see [14] for an overview. However, timetable net-
works are very dierent from road networks [15] and there is only little work
on speed-up techniques for them. Goal-directed search (A*) brings basic speed-
up [16,17,11,18]. Time-dependent SHARC [19] brings better speed-up by using
arc ags in the same scenario as we do and achieves query times of 2 ms but with
preprocessing times of more than 5 hours
2
. Based on the station graph model,
[13] also applied some speed-up techniques, namely arc ags that are valid on
1
Note that the time-dependent model is a special technique to model the time-
dependent information rather than an umbrella term for all these models.
2
We scaled timings by a factor of 0.42 compared to [14] based on plain Dijkstra
timings.
time periods and route contraction. They could not use node contraction be-
cause there were too many parallel edges between stations. Their preprocessing
time is over 33 CPU hours resulting in a full day prole query time of more
than 1 second (speed-up factor 5.2). These times are 2-3 orders of magnitude
slower than ours but a comparison is not possible since they use a fully realistic
bi-criteria scenario with footpaths, trac days and graphs that are not available
to us.
2 Preliminaries
We propose a model that is similar to the realistic time-dependent model intro-
duced in [11], but we keep a one-to-one mapping between nodes in the graph
and real stations.
A timetable consists of data concerning: stations (or bus stops, ports, etc),
trains (or buses, ferries, etc), connecting stations, departure and arrival times of
trains at stations, and trac days. More formally, we are given a set of stations B,
a set of stop events :
S
per station S B, and a set of elementary connections
(, whose elements c are 6-tuples of the form c = (Z
1
, Z
2
, S
1
, S
2
, t
d
, t
a
). Such
a tuple (elementary connection) is interpreted as train that leaves station S
1
at time t
d
after stop Z
1
and the immediately next stop is Z
2
at station S
2
at time t
a
. If x denotes a tuples eld, then the notation of x(c) species the
value of x in the elementary connection c. A stop even is the consecutive arrival
and departure of a train at a station, where no transfer is required. For the
corresponding arriving elementary connection c
1
and the departing one c
2
holds
Z
2
(c
1
) = Z
1
(c
2
). If a transfer between some elementary connections c
1
and c
2
at station S
2
(c
1
) = S
1
(c
2
) is required, Z
2
(c
1
) ,= Z
1
(c
2
) must hold. We introduce
additional stop events for the begin (no arrival) and the end (no departure) of
a train.
The departure and arrival times t
d
(c) and t
a
(c) of an elementary connection
c ( within a day are integers in the interval [0, 1439] representing time in
minutes after midnight. Given two time values t and t
, t t
, the cycledier-
ence(t, t
t (mod 1440).
The length of an elementary connection c, denoted by length(c), is cycledier-
ence(t
d
(c), t
a
(c)). We generally assume that trains operate daily but our model
can be extended to work with trac days. At a station S B, it is possible
to transfer from one train to another, if the time between the arrival and the
departure at the station S is larger than or equal to a given, station-specic,
minimum transfer time, denoted by transfer(S).
Let P = (c
1
, . . . , c
k
) be a sequence of elementary connections together with
departure times dep
i
(P) and arrival times arr
i
(P) for each elementary connec-
tion c
i
, 1 i k. We assume that the times dep
i
(P) and arr
i
(P) also include
day information to model trips that last longer than a day. Dene S
1
(P) :=
S
1
(c
1
), S
2
(P) := S
2
(c
k
), Z
1
(P) := Z
1
(c
1
), Z
2
(P) := Z
2
(c
k
), dep(P) := dep
1
(P),
and arr(P) := arr
k
(P). Such a sequence P is called a consistent connection
from station S
1
(P) to S
2
(P) if it fullls the following two consistency condi-
tions: (1) the departure station of c
i+1
is the arrival station of c
i
; (2) the time
values dep
i
(P) and arr
i
(P) correspond to the time values t
d
and t
a
, resp., of the
elementary connections (modulo 1440) and respect the transfer times at stations.
Given a timetable, we want to solve the earliest arrival problem (EAP), i.e.
to compute the earliest arriving consistent connection between given stations A
and B departing not earlier than a specied time t
0
. We refer to the algorithm
that solves the EAP as time query. In contrast, a prole query computes an
optimal set of all consistent connections independent of the departure time.
3 Station Graph Model
We introduce a model that represents a timetable as a directed graph G = (B, E)
with exactly one node per station. For a simplied model without transfer times,
this is like the time-dependent model. The novelty is that even with positive
transfer times, we keep one node per station and require no parallel edges. The
attribute of an edge e = (A, B) E is a set of consistent connections fn(e)
that depart at A and arrive at B, usually all elementary connections. Here and
in the following we assume that all connections are consistent. Previous models
required that all connections of a single edge fulll the FIFO-property, i. e. they
do not overtake each other. In contrast, we do not require this property. So we
can avoid parallel edges, as this is important for CH preprocessing. However,
even for time queries, we need to consider multiple dominant arrival events per
station.
We say that a connection P dominates a connection Q if we can replace
Q by P (Lemma 1). More formally, let Q be a connection. Dene parr(Q) as
the (previous) arrival arrival time of the train at station S
1
(Q) before it de-
parts at time dep(Q), or if this train begins there. If parr(Q) ,= then we
call res
d
(Q) := dep(Q) parr(Q) the residence time at departure. We call Q
a critical departure when parr(Q) ,= and res
d
(Q) < transfer(S
1
(Q)). Sym-
metrically, we dene ndep(Q) as the (next) departure time of the train at
station S
2
(Q), or if the train ends there. When ndep(Q) ,= then we call
res
a
(Q) := ndep(Q) arr(Q) the residence time at arrival. And Q is a critical
arrival when ndep(Q) ,= and res
a
(Q) < transfer(S
2
(Q)).
A connection P dominates Q i all of the following conditions are fullled:
(1) S
1
(P) = S
1
(Q) and S
2
(P) = S
2
(Q)
(2) dep(Q) dep(P) and arr(P) arr(Q)
(3) Z
1
(P) = Z
1
(Q), or Q is not a critical departure, or dep(P) parr(Q)
transfer(S
1
(P))
(4) Z
2
(P) = Z
2
(Q), or Q is not a critical arrival, or ndep(Q) arr(P)
transfer(S
2
(P))
Conditions (1),(2) are elementary conditions. Conditions (3),(4) are necessary
to respect the minimum transfer times, when Q is a subconnection of a larger
connection.
Given connection R = (c
1
, . . . , c
k
), we call a connection (c
i
, . . . , c
j
) with
1 i j k a subconnection of R, we call it prex i i = 1 and sux i j = k.
Lemma 1. A consistent connection P dominates a consistent connection Q i
for all consistent connections R with subconnection Q, we can replace Q by P
to get a consistent connection R
) arr(R
) arr(R).
3.1 Time Query
In this section we describe our baseline algorithm to answer a time query (A, B, t
0
).
We use a Dijkstra-like algorithm on our station graph that stores labels with each
station and incrementally corrects them. A label is a connection P stored as a
tuple (Z
2
, arr)
3
, where Z
2
is the arrival stop event and arr is the arrival time
including days. The source station is always A, the target station S
2
(P) is im-
plicitly given by the station that stores this label. Furthermore, we only consider
connections departing not earlier than t
0
at A and want to minimize the arrival
time. As we do not further care about the actual departure time at A, we call
such a connection arrival connection. We say that an arrival connection P dom-
inates Q i all of the following conditions are fullled:
(1) S
2
(P) = S
2
(Q)
(2) arr(P) arr(Q)
(3) Z
2
(P) = Z
2
(Q), or Q is not a critical arrival, or ndep(Q) arr(P)
transfer(S
2
(P))
Lemma 2 shows that dominant arrival connections are sucient for a time
query.
Lemma 2. Let (A, B, t
0
) be a time query. A consistent arrival connection P
dominates a consistent arrival connection Q i for all consistent arrival con-
nections R with prex Q, we can replace Q by P to get a consistent arrival
connection R
with arr(R
) arr(R).
Our algorithm manages a set of dominant arrival connections ac(S) for each
station S. The initialization of ac(A) at the departure station A is a special
case since we have no real connection to station A. That is why we introduce a
special stop event and we start with the set (, t
0
) at station A. Our query
algorithm then knows that we are able to board all trains that depart not earlier
than t
0
. We perform a label correcting query that uses the minimum arrival
time of the (new) connections as key of a priority queue. This algorithm needs
two elementary operations: (1) link: We need to traverse an edge e = (S, T) by
linking a given set of arrival connections ac(S) with the connections fn(e) to get
a new set of arrival connections to station T. (2) minimum: We need to combine
the already existing arrival connections at T with the new ones to a dominant
set. We found a solution to the EAP once we extract a label of station B from
the priority queue, as Theorem 1 proves.
Theorem 1. The time query in the station graph model solves the EAP.
3
Such a label does not uniquely describe a connection but stores all relevant infor-
mation for a time query.
Proof. The query algorithm only creates consistent connections because link
and minimum do so. Lemma 2 ensures that there is never a connection with
earlier arrival time. The connections depart from station A not before t
0
by
initialization. Since the length of any connection is non-negative, and by the
order in the priority queue, the rst label of B extracted from the priority queue
represents a solution to the EAP.
The link and minimum operation dominate the runtime of the query algo-
rithm. The most important part is a suitable order of the connections, primarily
ordered by arrival time. The minimum operation is then mainly a linear merge
operation, and the link operation uses precomputed intervals to look only at a
small relevant subset of fn(e). We gain additional speed-up by combining the
link and minimum operation.
3.2 Prole Query
A prole query (A, B) is similar to a time query. However, we compute dominant
connections con(S) instead of dominant arrival connections. Also we cannot just
stop the search when we remove a label of B from the priority queue for the
rst time. We are only allowed to stop the search when we know that we have a
dominant set of all consistent connections between A and B. For daily operating
trains, we can compute a maximum length for a set of connections and can use
it to prune the search. The ecient implementations of the minimum and link
operation are also more complex. Similar to a time query, we use a suitable order
of the connections, primarily ordered by departure time. The minimum operation
is an almost linear merge: we merge the connections in descending order and
remove dominated ones. This is done with a sweep buer that keeps all previous
dominant connections that are relevant for the current departure time. The link
operation, which links connections from station A to S with connections from
station S to T, is more complex: in a nutshell, we process the sorted connections
from A to S one by one, compute a relevant interval of connections from S to T
as for the time query, and remove dominated connections using a sweep buer
like for the minimum operation.
4 Contraction Hierarchies (CH)
CH performs preprocessing based on node contraction to accelerate queries. Con-
tracting a node (= station) v in the station graph removes v and all its adjacent
edges from the graph and adds shortcut edges to preserve dominant connections
between the remaining nodes. A shortcut edge bypasses node v and represents
a set of whole connections. Practically, we contract one node at a time until
the graph is empty. All original edges together with the shortcut edges form the
result of the preprocessing, a CH.
4.1 Preprocessing
The most time consuming part of the contraction is the witness search: given a
node v and an incoming edge (u, v) and an outgoing edge (v, w), is a shortcut
between u and w necessary when we contract v? We answer this question usually
by a one-to-many prole search from u omitting v (witness search). If we nd
for every connection of the path u, v, w a dominating connection (witness),
we can omit a shortcut, otherwise we add a shortcut with all the connections
that have not been dominated. To keep the number of prole searches small,
we maintain a set of necessary shortcuts for each node v. They do not take
a lot of space since timetable networks are much smaller than road networks.
Then, the contraction of node v is reduced to just adding the stored shortcuts.
Initially, we perform a one-to-many prole search from each node u and store
with each neighbor v the necessary shortcuts (u, w) that bypass v. The search
can be limited by the length of the longest potential shortcut connection from u.
After the contraction, we need to update the stored shortcuts of the remaining
nodes. The newly added shortcuts (u, w) may induce other shortcuts for the
neighbors u and w. So we perform one forward prole search from u and add to
w the necessary shortcuts (u, x) bypassing w. A backward prole search from w
updates node u. To omit the case that two connections witness each other, we
add a shortcut when the witness has the same length and is not faster. So at
most two prole searches from each neighbor of v are necessary. When we add
a new shortcut (u, w), but there is already an edge (u, w), we merge both edges
using the minimum operation, so there are never parallel edges. Avoiding these
parallel edges is important for the contraction, which performs worse on dense
graphs. Thereby, we also ensure that we can uniquely identify an edge with its
endpoints.
We also limit the number of hops and the number of transfers of a witness
search. As observed in [2], this accelerates the witness search at the cost of
potentially more shortcuts.
We could omit loops in static and time-dependent road networks. But for
station graph timetable networks, loops are sometimes necessary when transfer
times dier between stations. For example, assume there is a train T1: (station
sequence) A B C and another train T2: C B D. A large minimum
transfer time at B and a small one at C can forbid the transfer from T1 to T2 at
B but make it possible at C. Contracting station C requires a loop at station B
to preserve the connection between A and D. These loops also make the witness
computation and the update of the stored shortcuts more complex. A shortcut
(u, w) for node v with loop (v, v) must not only represent the path u, v, w,
but also u, v, v, w. So when we add a shortcut (v, v) during the contraction of
another node, we need to recompute all stored shortcuts of node v.
The order in which the nodes are contracted is deduced from a node priority
consisting of: (a) The edge quotient, the quotient between the amount of short-
cuts added and the amount of edge removed from the remaining graph. (b) The
hierarchy depth, an upper bound on the amount of hops that can be performed
in the resulting hierarchy. Initially, we set depth(u) = 0 and when a node v is
contracted, we set depth(u) = max(depth(u),depth(v)+1) for all neighbors u.
We weight (a) with 10 and (b) with 1 in a linear combination to compute the
node priorities. Nodes with higher priority are more important and get con-
tracted later. The nodes are contracted by computing independent node sets
with a 2-neighborhood [20]. Also note that [2,3] perform a simulated contraction
of a node to compute its edge quotient. [20] improves this by caching witnesses,
but still needs to perform a simulated contraction when a shortcut is necessary.
We can omit this due to our stored sets of necessary shortcuts.
Interestingly, we cannot directly use the algorithms used for time-dependent
road networks [3]. We tried using the time-dependent model for the timetable
networks, but too many shortcuts were added, especially a lot of shortcuts be-
tween the dierent train-route nodes of the same station pair occur.
4
Addition-
ally, [3] strongly base their algorithm on min-max search that only uses the time-
independent min./max. length of an edge to compute upper and lower bounds.
However, in timetable networks, the max. travel time for an edge is very high,
e. g. when there is no service during the night. So the computed upper bounds
are too high to bring any exploitable advantages. Without min-max search, the
algorithm of [3] is drastically less ecient, i. e. the preprocessing takes days in-
stead of minutes.
4.2 Query
Our query is a bidirectional Dijkstra-like query in the CH. A directed edge (v, w),
where w is contracted after v, is an upward edge, otherwise a downward edge.
Our forward search only relaxes upward edges and our backward search only
downward edges [2]. The node contraction ensures the correctness of the search.
For a CH time query, we do not know the arrival time at the target node.
We solve this by marking all downward edges that are reachable from the tar-
get node. The standard time query algorithm, using only upward edges and
the marked downward edges, solves the EAP. The CH prole query is based
on the standard prole query algorithm. Note that using further optimizations
that work for road networks (stall-on-demand, min-max search) [3] would even
slowdown our query.
5 Experiments
Environment. The experimental evaluation was done on one core of a Intel Xeon
X5550 processors (Quad-Core) clocked at 2.67 GHz with 48 GiB of RAM
5
and
2x8MiB of Cache running SUSE Linux 11.1 (kernel 2.6.27). The program was
compiled by the GNU C++ compiler 4.3.2 using optimization level 3.
4
We tried to merge train-route nodes but this brought just small improvements.
5
We never used more than 556 MiB of RAM, reported by the kernel.
Table 1. Network sizes and number of nodes and edges in the graph for each
model.
trains/ elementary time-dependent station based
network stations buses connections nodes edges nodes edges
eur-longdist 30 517 167 299 1 669 666 550 975 1 488 978 30 517 88 091
ger-local1 12 069 33 227 680 176 228 874 599 406 12 069 33 473
ger-local2 9 902 60 889 1 128 465 167 213 464 472 9 902 26 678
Table 2. Performance of the station graph model compared to the time-
dependent model on plain Dijkstra queries. We report the total space, the #delete
mins from the priority queue, query times, and the speed-up compared to the
time-dependent model.
time-queries profile-queries
space #delete spd time spd #delete spd time spd
network model [MiB] mins up [ms] up mins up [ms] up
eur- time-dep. 27.9 259 506 1.0 54.3 1.0 1 949 940 1.0 1 994 1.0
longdist station 48.3 14 504 17.9 9.4 5.8 48 216 40.4 242 8.2
ger- time-dep. 11.3 112 683 1.0 20.9 1.0 1 167 630 1.0 1 263 1.0
local1 station 19.6 5 969 18.9 4.0 5.2 33 592 34.8 215 5.9
ger- time-dep. 10.9 87 379 1.0 16.1 1.0 976 679 1.0 1 243 1.0
local2 station 29.3 5 091 17.2 3.5 4.6 27 675 35.3 258 4.8
Test Instances. We have used real-world data from the European railways. The
network of the long distance connections of Europe (eur-longdist) is from the
winter period 1996/97. The network of the local trac in Berlin/Brandenburg
(ger-local1) and of the Rhein/Main region in Germany (ger-local2) are from
the winter period 2000/01. The sizes of all networks are listed in Table 1.
Results. We selected 1 000 random queries and give average performance mea-
sures. We compare the time-dependent model and our new station model using
a simple unidirectional Dijkstra algorithm in Table 2. Time queries have a good
query time speed-up above 4.5 and even more when compared to the number of
delete mins. However, since we do more work per delete min, this dierence is
expected. Prole queries have very good speed-up around 5 to 8 for all tested
instances. Interestingly, our speed-up of the number of delete mins is even better
than for time queries. We assume that more re-visits occur since there are often
parallel edges between a pair of stations represented by its train-route nodes.
Our model does not have this problem since we have no parallel edges and each
station is represented by just one node. It is not possible to compare the space
consumption per node since the number of nodes is in the dierent models dif-
ferent. So we give the absolute memory footprint: it is so small that we did not
even try to reduce it, altough there is some potential.
Before we present our results for CH, we would like to mention that we
were unable to contract the same networks in the time-dependent model. The
contraction took days and the average degree in the remaining graph exploded.
Even when we contracted whole stations with all of its route nodes at once, it
did not work. It failed since the necessary shortcuts between all the train-route
nodes multiplied quickly. So we developed the station graph model to x these
problems. Table 3 shows the resulting preprocessing and query performance. We
get preprocessing times between 3 to 4 minutes using a hop limit of 7. The
number of transfers is limited to the maximal number of transfers of a potential
shortcut + 2. These timings are exceptional low (minutes instead of hours)
compared to previous publications [19,13] and reduce time queries below 550 s
for all tested instances. CH work very well for eur-longdist where we get speed-
ups of more than 37 for time queries and 65 for prole queries. When we multiply
the speed-up of the comparison with the time-dependent model, we even get a
speed-up of 218 (time) and 534 (prole) respectively. These speed-ups are one
order of magnitude larger than previous speed-ups [19]. The network ger-local2
is also suited for CH, the ratio between elementary connections and stations
is however very high, so there is more work per settled node. More dicult is
ger-local1; in our opinion, this network is less hierarchically structured. We see
that on the eect of dierent hop limits for precomputation. (We chose 7 as a hop
limit for fast preprocessing and then selected 15 to show further tradeo between
preprocessing and query time.) The smaller hop limit increases time query times
by about 25%, whereas the other two networks just suer an increase of about
16%. So important witnesses in ger-local1 contain more edges, indicating a
lack of hierarchy.
We do not really have to worry about preprocessing space since those net-
works are very small. The number of edges roughly doubles for all instances.
We observe similar results for static road networks [2], but there we can save
space with bidirectional edges. But in timetable networks, we do not have bidi-
rectional edges with the same weight, so we need to store them separately. CH
on timetable networks are inherently space ecient as they are event-based, they
increase the memory consumption by not more than a factor 2.4 (ger-local1:
19.6 MiB 47.5 MiB). In contrast, CH time-dependent road networks are not
event-based and get very complex travel time functions on shortcuts, leading to
an increased memory consumption (Germany midweek: 0.4 GiB 4.4 GiB).
Recent work reduces the space consumption by using approximations to answer
queries exactly [21].
6 Conclusions
Our work has two contributions. First of all the station graph model, which
has just one node per station, is clearly superior to the time-dependent model
for the given scenario. Although the link and minimum operations are more
expensive, we are still faster than in the time-dependent model since we need
to execute them less often. Also all known speed-up techniques that work for
the time-dependent model should work for our new model. Most likely, they
even work better since the hierarchy of the network is more visible because of
the one-to-one mapping of stations to nodes and the absence of parallel edges.
Table 3. Performance of CH. We report the preprocessing time, the space over-
head and the increase in edge count. For query performance, we report the
#delete mins from the priority queue, query times, and the speed-up over a
plain Dijkstra (Table 2).
preprocessing time-queries profile-queries
hop- time space edge #del. spd time spd #del. spd time spd
network limit [s] [MiB] inc. mins up [s] up mins up [ms] up
eur- 7 210 45.7 88% 192 75.7 251 37.5 260 186 3.7 65.1
longdist 15 619 45.3 86% 183 79.3 216 43.5 251 192 3.4 71.4
ger- 7 216 27.9 135% 207 28.8 544 7.3 441 76 27.0 8.0
local1 15 685 26.9 128% 186 32.1 434 9.2 426 79 24.2 8.9
ger- 7 167 36.0 123% 154 33.1 249 14.0 237 117 9.5 27.1
local2 15 459 35.0 117% 147 34.6 217 16.1 228 121 8.2 31.3
Our second contribution is the combination of the CH algorithm and the station
graph model. With preprocessing times of a few minutes, we answer time queries
in half a millisecond. Our algorithm is therefore suitable for web services with
high load, where small query times are very important and can compensate for
our restricted scenario.
In our opinion, our presented ideas build the algorithmic core to develop
ecient algorithms in more realistic scenarios. Especially the successful demon-
stration of the contraction of timetable networks brings speed-up techniques to
a new level. It allows to reduce network sizes and to apply other speed-up tech-
niques only to a core of the hierarchy, even in case that the contraction of all
nodes is infeasible.
References
1. Delling, D., Sanders, P., Schultes, D., Wagner, D.: Engineering Route Planning
Algorithms. In Lerner, J., Wagner, D., Zweig, K.A., eds.: Algorithmics of Large and
Complex Networks. Volume 5515 of Lecture Notes in Computer Science. Springer
(2009) 117139
2. Geisberger, R., Sanders, P., Schultes, D., Delling, D.: Contraction Hierarchies:
Faster and Simpler Hierarchical Routing in Road Networks. [22] 319333
3. Batz, G.V., Delling, D., Sanders, P., Vetter, C.: Time-Dependent Contraction
Hierarchies. In: Proceedings of the 11th Workshop on Algorithm Engineering and
Experiments (ALENEX09), SIAM (April 2009) 97105
4. M ullerHannemann, M., Weihe, K.: Pareto Shortest Paths is Often Feasible in
Practice. In: Proceedings of the 5th International Workshop on Algorithm Engi-
neering (WAE01). Volume 2141 of Lecture Notes in Computer Science., Springer
(2001) 185197
5. Marcotte, P., Nguyen, S., eds.: Equilibrium and Advanced Transportation Mod-
elling. Kluwer Academic Publishers Group (1998)
6. Schulz, F., Wagner, D., Weihe, K.: Dijkstras Algorithm On-Line: An Empiri-
cal Case Study from Public Railroad Transport. ACM Journal of Experimental
Algorithmics 5 (2000) 12
7. Brodal, G., Jacob, R.: Time-dependent Networks as Models to Achieve Fast Exact
Time-table Queries. [23] 315
8. Nachtigall, K.: Time depending shortest-path problems with applications to rail-
way networks. European Journal of Operational Research 83(1) (1995) 154166
9. Orda, A., Rom, R.: Shortest-Path and Minimum Delay Algorithms in Networks
with Time-Dependent Edge-Length. Journal of the ACM 37(3) (1990) 607625
10. Orda, A., Rom, R.: Minimum Weight Paths in Time-Dependent Networks. Net-
works 21 (1991) 295319
11. Pyrga, E., Schulz, F., Wagner, D., Zaroliagis, C.: Ecient Models for Timetable
Information in Public Transportation Systems. ACM Journal of Experimental
Algorithmics 12 (2007) Article 2.4
12. Berger, A., M ullerHannemann, M.: Subpath-Optimality of Multi-Criteria Short-
est Paths in Time- and Event-Dependent Networks. Technical Report 1, University
Halle-Wittenberg, Institute of Computer Science (2009)
13. Berger, A., Delling, D., Gebhardt, A., M ullerHannemann, M.: Accelerating Time-
Dependent Multi-Criteria Timetable Information is Harder Than Expected. In:
Proceedings of the 9th Workshop on Algorithmic Approaches for Transportation
Modeling, Optimization, and Systems (ATMOS09). Dagstuhl Seminar Proceed-
ings (2009)
14. Delling, D., Wagner, D.: Time-Dependent Route Planning. In Ahuja, R.K.,
M ohring, R.H., Zaroliagis, C., eds.: Robust and Online Large-Scale Optimization.
Volume 5868 of Lecture Notes in Computer Science. Springer (2009) 207230
15. Bast, H.: Car or Public Transport Two Worlds. In Albers, S., Alt, H., N aher, S.,
eds.: Ecient Algorithms. Volume 5760 of Electronic Notes in Theoretical Com-
puter Science. Springer (2009) 355367
16. Hart, P.E., Nilsson, N., Raphael, B.: A Formal Basis for the Heuristic Deter-
mination of Minimum Cost Paths. IEEE Transactions on Systems Science and
Cybernetics 4 (1968) 100107
17. Pyrga, E., Schulz, F., Wagner, D., Zaroliagis, C.: Towards Realistic Modeling of
Time-Table Information through the Time-Dependent Approach. [23] 85103
18. Disser, Y., M ullerHannemann, M., Schnee, M.: Multi-Criteria Shortest Paths in
Time-Dependent Train Networks. [22] 347361
19. Delling, D.: Time-Dependent SHARC-Routing. Algorithmica (July 2009) Special
Issue: European Symposium on Algorithms 2008.
20. Vetter, C.: Parallel Time-Dependent Contraction Hierarchies (2009) Student Re-
search Project. http://algo2.iti.kit.edu/documents/routeplanning/vetter_
sa.pdf.
21. Batz, G.V., Geisberger, R., Neubauer, S., Sanders, P.: Time-Dependent Contrac-
tion Hierarchies and Approximation. In: Proceedings of the 9th International
Symposium on Experimental Algorithms (SEA10). Lecture Notes in Computer
Science, Springer (2010)
22. McGeoch, C.C., ed.: Proceedings of the 7th Workshop on Experimental Algo-
rithms (WEA08). In McGeoch, C.C., ed.: Proceedings of the 7th Workshop on
Experimental Algorithms (WEA08). Volume 5038 of Lecture Notes in Computer
Science., Springer (June 2008)
23. Proceedings of the 3rd Workshop on Algorithmic Methods and Models for Op-
timization of Railways (ATMOS03). In: Proceedings of the 3rd Workshop on
Algorithmic Methods and Models for Optimization of Railways (ATMOS03). Vol-
ume 92 of Electronic Notes in Theoretical Computer Science. (2004)
A Examples
Example 1. This is an example timetable with elementary connections. (1, 1,
A, B, 23:05, 0:55), (1, 1, B, C, 1:02, 2:57), (1, 1, C, D, 3:00,4:20) describe
elementary connections of a train from station A via stations B, C to station
D as shown in Figure ??. The train departs at station A at 23:05 (hh:mm)
and arrives at station B at 0:55 the next day. The length of this elementary
connection is 1:50 = 110 minutes. (2, 1, C, E, 3:00, 4:00), (3, 2, C, E, 4:00,
5:00) describe elementary connections of two trains from station C to E, the
rst train departs at 3:00 and arrives at 4:00, the second train one hour later.
We omitted the minimum transfer times of the stations.
A B C D
E
(1, 1, A, B, 23:05, 0:55) (1, 1, B, C, 1:02, 2:57) (1, 1, C, D, 3:00,4:20)
(2, 1, C, E, 3:00, 4:00) (3, 2, C, E, 4:00, 5:00)
Fig. 1. Every node represents a station and every edge a set of elementary
connections.
Example 2.
c
i
(Z
1
, Z
2
, S
1
, S
2
, t
d
, t
a
) dep
i
arr
i
c
1
(1, 1, A, B, 23:05, 0:55) 23:05 24:55
c
2
(1, 1, B, C, 1:02, 2:57) 25:02 26:57
c
3
(3, 2, C, E, 4:00, 5:00) 28:00 29:00
P = (c
1
, c
2
, c
3
) is a consistent connection with one transfer. The elementary
connections are from Example ??. Assume a transfer time at station C of 5
minutes. It would not be consistent to replace c
3
with the train that arrives at
arr
3
(P) = 28:00 since there are only 3 < 5 = transfer(C) minutes between the
arrival and the departure at station C.
Example 3. This example explains the motivation for the notion of a critical
departure/arrival. Let our timetable be given by Figure ??. As each edge repre-
sents just a single elementary connection, we can represent connections by their
sequence of stations.
Let Q be the connection B C E and let P be the connection B D
E. Both connections are consistent and some of their attributes are summarized
in Table ??. Let us decide whether connection P dominates connection Q, i.e.
we can replace connection Q by P. The conditions (1) and (2) from Section 3
are already fullled. Both depart at 9:10 and the length of Q is 10 minutes and
the length of P is 9 minutes. At rst glance, it might look like we can replace Q
by P.
However, if Q appears as subconnection of a larger connection, the result may
not be consistent. Let R be the connection A B C E F. Connection
R is consistent as it is a single train from A to F without any transfers. Q is
a subconnection of R. When we replace Q by P in R, we get a connection R
is
not consistent. The reason is that between the arrival of at B at 9:06 and the
departure at 9:10 are only 4 minutes time, this is smaller than the minimum
transfer time of 5 minutes. If R would arrive earlier, e.g. at 9:05, the transfer
would be consistent, res
d
(Q) would increase to 5 minutes and Q would not be
a critical departure.
Note that at station E we have a dierent situation as at station B altough Q
is a critical arrival (at E). There, the transfer of R
), we
can link P with Q
) + d and thus
arr(Q) = dep(Q) + length(Q) dep(Q) + length(Q
) + d (dep(Q
) d
transfer(S
2
)) +length(Q
) +d arr(Q
) transfer(S
2
). When Q
has a critical
arrival, then arr(Q
) ndep(Q
.
E.2 Operations on Connections
Linking two edges for shortcuts and prole search uses the dominant range
computation at link time. We change the order of the connections in the array
for this operation. They are still primarily ordered by departure. But within the
same departure time, the dominant connection should be after the dominated
one. That allows for an ecient backward scan to remove dominated connections.
So we secondarily order by length descending, thirdly non-critical before critical
departure, and nally non-critical before critical arrival. Finally, we order by
the rst and last stop event, preferring a stop event with critical departure or
arrival. The last criterion is necessary for an ecient building of a dominant
union (minimum) of two connection sets where the preference is on one set.
Given two edges e
1
= (S
1
, S
2
) and e
2
= (S
2
, S
3
), we want to link all consis-
tent connections to create fn(e
3
) for an an edge e
3
= (S
1
, S
3
). A trivial algorithm
would link each consistent pair of connections in fn(e
1
) and fn(e
2
) and then com-
pare each of the resulting connections with all other connections to nd a dom-
inant set of connections. However, this is impractical for large g = [fn(e
1
)[ and
h = [fn(e
2
)[. We would create (g h) new connections and do up to
(gh)
2
comparisons.
So we propose a dierent strategy for linking that is considerably faster for
practical instances. We process the connections in fn(e
1
) in descending order.
Given a connection P, we want to nd a connection Q that dominates P at
the departure at S
1
. So we only need to link P to connections in fn(e
2
) that
depart in S
2
after the arrival of P but before the arrival of Q. Preferably we
want to nd the Q with the earliest arrival time. However, we nd the Q with
the earliest arrival time in S
2
with dep(Q) dep(P) +transfer(S
2
). Then Q will
not only dominate P at the departure but also any connection departing not
later than P. So we can use a simple nger search to nd Q. Now we link P only
to connections in fn(e
2
) departing between the arrival of P and Q. We use nger
search to nd the rst connection that departs in fn(e
2
) after the arrival of P.
Of course, we need to take the transfer time at S
2
into account when we link. It
is not always necessary to link to all connections that depart before Q arrives;
we can use the knowledge of the minimum length in fn(e
2
) to stop linking when
we cannot expect any new dominant connections. The newly linked connections
may (1) not be dominant and also may (2) not be in order.
(1) To remove dominated connections, we use a sweep buer that has as
state the current departure time and holds all relevant connections with higher
order to dominate a connection with the current departure time. The number of
relevant connections is usually small. We need at most all the connections that
depart less than transfer(S
1
) later than the current departure time and also all
connections that depart at least transfer(S
1
) later than the current departure
time but their arrival time is not more than transfer(S
3
) later than the current
earliest arrival time. Assuming that only few connections depart in S
1
within
transfer(S
1
) minutes, and only few connections arrive in S
3
within transfer(S
3
)
minutes, the sweep buer has only a few entries.
(2) Connections can only be unordered within a range with same departure
time, e. g. when they have ascending lengths. So we use the idea of insertion
sort to reposition a connection that is not in order. While we reposition a new
connection, we must check whether it dominates the connections that are now
positioned before it. E.g. a new connection with same departure than the pre-
vious one but smaller length may dominate the previous one if the departure is
not critical.
After we processed all connections in fn(e
1
), we have a superset of fn(e
3
)
that is already ordered, but some connections may be dominated. This happens
when the dominant connection departs after midnight and the dominated con-
nection before, so the periodic border is between them. To remove all dominated
connections, we continue scanning backwards through the new connections but
now on day -1 using the sweep buer. We can stop when no connection in the
sweep buer is of day 0.
Running time. We give an idea why this link operation is very fast and may work
in linear time in many cases. The experiments in Section 5 show that it is indeed
very ecient. Let c
P
be the size of the range in fn(e
3
) that departs between the
arrival of P and Q. Let b
P
be the runtime of the nger search to nd the earliest
connection in fn(e
2
) that departs after the arrival of P Let s be the maximum
number of relevant connections in the sweep buer. The runtime of link is then
O
Pfn(e1)
(c
P
s +b
P
)
Pfn(e1)
(c
P
+b
P
) = O(g +h), we get
a runtime of O((g +h)s). As we already argued when we described the sweep
buer, s is small and in many cases constant, so our runtime should be O(g +h)
in many cases.
network cP
Pfn(e
1
)
c
P
g+h
bP
Pfn(e
1
)
b
P
g+h
Pfn(e
1
)
(c
P
+b
P
)
g+h
s
eur-longdist 0.93 0.29 3.25 0.84 1.14 2.34
ger-local1 1.26 0.29 3.97 0.93 1.22 3.85
ger-local2 1.44 0.30 4.30 1.08 1.38 5.30
Table 6. Average of 1 000 random prole queries.
Constructing the Minimum of two Sets of Connections. Query algorithms need
two basic operations: link and minimum. For newly visited nodes only link is
relevant, but usually a minimum follows a link, so it is ecient to integrate both.
But rst we will describe a standalone minimum operation, we use it to compare
witness paths and possible shortcuts. It is basically a backwards merge of the
ordered arrays of connections and uses a sweep buer as for the link operation.
Similar the link operation, we continue backward scanning on day -1 to get
rid of dominated connections over the periodic border.
Like for an arrival connection, two connections are equivalent when they have
the same length, an equivalent departure and equivalent arrival. Two connections
P and Q have an equivalent departure when their departure is identical or when
the departure is not critical and they have the same departure time. Analogously,
two connections P and Q have an equivalent arrival when their arrival is identical
or when the arrival is not critical and they have the same arrival time. Because of
the order, equivalent connections are next to each other. So we can easily detect
them during the merge. Tie breaking is done in a way to reduce the number of
priority queue operations.
Running time. Let g and h be the cardinalities of the two sets we merge. Let
s be the maximum size of the sweep buer. Then, the runtime of the minimum
operation is O((g +h)s). Since s is small and in many cases constant, the runtime
should be O(g +h) in many cases. To show that our link and minimum operation
are empirically fast, we give the average of the parameters we used to bound our
runtime in Table ??.
Integrating Link and Minimum. A minimum operation always follows a link op-
eration when we relax an edge to an already reached station S. This happens
quite often for prole queries, so we can exploit this to tune our algorithm. We
directly process the newly linked connections one by one and directly merge
them with the current connections at S. When a new connection is not in or-
der, we x this with the insertion sort idea. The rest is like in the stand-alone
minimum operation. This integration reduces required memory allocations and
gives signicant speed-ups.