Edges as Nodes - THI - Leibniz Universität Hannover

Leibniz Universität Hannover
Institut für Theoretische Informatik
Diplom Thesis
Edges as Nodes
A New Approach to Timetable Information
by
Yevgen Nebesov
Supervisors: Prof. Dr. Heribert Vollmer,
Prof. Dr. Wolfgang Nejdl
Hannover, 2010
Acknowledgement
I want to thank Dr. Olaf Beyersdor for the big help in establishing the theory, algorithms design, and proofs of the theorems, and also for his transnational supervision of my thesis.
1
Contents
1
Introduction
5
2
Shortest Path Problems: History and Scope
7
3
Itinerary Problems : Formulations and Common Solutions
3.1
4
5
6
10
EAP and MNTP as Representatives of Shortest Path Problems 11
The Time-Expanded Model
13
4.1
EAP with the Time-Expanded Model . . . . . . . . . . . . . .
15
4.2
MNTP with the Time-Expanded Model . . . . . . . . . . . . .
16
The Time-Dependent Model
17
5.1
EAP with the Time-Dependent Model
. . . . . . . . . . . . .
5.2
MNTP with the Time-Dependent Model
. . . . . . . . . . . .
17
18
The Edge-Converted Model
19
6.1
EAP and MNTP with the Edge-Converted Model . . . . . . .
23
6.1.1
EAP with the Edge-Converted Model . . . . . . . . . .
23
6.1.2
MNTP with the Edge-Converted Model . . . . . . . . .
26
7
Performance Comparison
28
8
Conclusion and Future Work
30
2
List of Figures
2.1
Classication of shortest-path problems
2.2
Classication of input networks for shortest-path algorithms
2.3
Classication of techniques for solving shortest-path problems
3.1
Trains between stations
. . . . . . .
12
4.1
An initial network . . . . . . . . . . . . . . . . . . . . . . . . .
14
4.2
The transformed time-expanded network
14
4.3
A time-expanded network with weights for EAP
4.4
A time-expanded network with weights for MNTP
6.1
A transformation into the edge-converted model : Step 1
. . .
20
6.2
A transformation into the edge-converted model : Step 2
. . .
20
6.3
A transformation into the edge-converted model : Step 3
. . .
20
6.4
A transformation into the edge-converted model : Step 4
. . .
20
6.5
An edge-converted network pre-processed for EAP. The num-
i
and
j
. . . . . . . . . . . .
and the plot of
fij
.
. . . . . . . . . . . .
9
9
. . . . . . .
15
. . . . . .
16
bers on the edges represent the ordering of the ingoing edges .
3
8
24
List of Tables
4.1
The size of the time-expanded graph
. . . . . . . . . . . . . .
6.1
A comparison of the size of the time-expanded, time-dependent
and edge-converted models . . . . . . . . . . . . . . . . . . . .
7.1
14
22
Experimental comparison of EAP and MNTP in the timeexpanded and time-dependent models (using
Dijkstra with
priority queue) and in the edge-converted model (Algorithms 1
and 2)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
29
Chapter 1
Introduction
Graphs or networks is a most helpful modelling tool in a broad spectrum
of industrial, research and public problems.
A number of algorithms on
graphs is studied in the literature and has been already used in dierent
applications[1]. Shortest-Path Algorithms is a big area of graph algorithms,
which are searching for a shortest route in a network between two nodes. In
this diplom thesis I research the applications of a Shortest-Path-Problems in
directed graphs in the area of public transportation networks.
One of the main tasks in public transportation systems is timetable information. Users of timetable information services search for a connection
between two stations, which should satisfy their travel requierement or/and
optimize some criteria, for example a travel time.
One of the most basic
timetable information problems is the earliest arrival problem (EAP ) asking
for a route between two stations
est possible arrival at
t
s
and
t.
This route should assure the earli-
and obey the specied departure time at
s.
Another
common problem in timetable information systems is the minimum number
of transfers problem (M N T P ), which asks for a route between two stations
s
and
t
minimizing a number of transfers at intermediate stations.
While the systems used in practice typically employ heuristics to solve
these problems(cf. [22]),there is also a number of exact methods. The most
common approaches are the time-expanded and time-dependent approaches,
which transform the initial network into a weighted digraph such that classical algorithms for path search as for example
Dijkstra become applicable
[6, 23, 25, 27]
In this thesis I propose a novel approach to timetable information which
5
I call the edge-converted approach. Similarly as in the time-expanded and
time-dependent model, the initial network will be converted into a digraph, so
that elementary connections are represented as nodes. Thus, in some sense,
the role of edges and nodes is switched in this model. Based on this model
I present two algorithms that solve the earliest arrival problem(EAP) as
well as the minimum number of transfers ptoblem(MNTP). Both algorithms
are conceptually simple as they are variants of depth-rst and breadth-rst
search, respectively. Moreover, these algorithms are very ecient - they only
use linear time in the size of their input, i.e, in terms of the size of the
edge-converted network.
To compare the performance of these algorithms to
Dijkstra-based ap-
proaches in the time-expanded model [27], it is needed to compare the sizes of
the time-expanded and edge-converted graphs. It turns out, that my model
has the advantage to introduce less nodes but uses far more edges (up to
O(n3 )
in the general case). However, I argue that only a linear number of
edges is needed for practical networks. This leads to linear-time algorithms
for EAP and MNTP. My approach yields linear time algorithms for EAP
and MNTP, in particular, for the class of constant-degree graaphs, where the
running time is measured in the size of the initial network. This improves
upon the known
Dijkstra-based solutions which consume O(n log n) run-
ning time. I also implemented our algorithms and performed an exprimental
study which conforms the theoretical results.
This thesis is based on the paper written jointly with Dr. O.Beyersdor[4]
and is organized as follows. In Sect. 2 I review a history of the shortest path
problems. In Sect. 3 I deliver denitions on timetable information including
the denition of EAP and MNTP and in Sect. 4 and 5 two main approaches
towards these problems are discussed. In Sect. 6 I introduce a new model
and compare it with the approaches from Sect. 4, 5. The following Sect. 7
contains a performance tests and a comparison for EAP and MNTP in all
considerd models. Finally, Sect. 8 concludes with a discussion of the results
and directions for future research.
6
Chapter 2
Shortest Path Problems: History
and Scope
EAP and MNTP are counted among the class of shortest-path problems
(SPP). These are by far the most fundamental and also most commonly
encountered problems in the study of transportation networks.
The rst SPP formulation can be found in the works of Bellman(1958) [3],
Ford(1956) [15], Moore(1959) [21] and Dijkstra(1959) [12]. Bellman proposed
a dynamic programming algorithm[2] for solving SPP with constant edge
length. This algorithm is an iterative one. It bears an exact solution of a
given SPP by insisting on some optimality criteria after a nite number of
iterations. Frieze [16] also suggested a dynamic programming algorithm for
shortest-path search, in which a path length is generalized to be a certain
class of real-valued function on paths. It can be also applied to the EAP or
MNTP, but no scientic research are carried on the topic.
Another interesting formulation of the shortest path problems can be
found in the work of Carré(1971) [7]. He dened an algebra with two operation, an addition and a multiplication, and demonstrated that in terms of
this algebra every shortest path problem may be posed as that of determining
a matrix Y which satises an equation
and
B
Y = AY + B ,
where the matrices
A
are specied.
In the next years the number of shortest path problems in connection
was signicantly expanded and depthly explored. In 1984 Deo and Pang [11]
made a classication of all to that moment existing shortest path problems
7
Shortest Path
Problems
Usual Path
Length
Generalized
Path Legth
Unconstrained
Path Legth
With Turn
Penalties
The Shortest Path
K-th Shortest Path
Sub-Optimal
Paths
Multiple Source
One-To-One
One-To-All
Algebraically
Related
Problems
Constrained
Path Legth
Path must go
through specified
Nodes
Single Source
Path Lenth as
Some Funcion
Path has
Specified Number
of Arcs
With Cycles
All Nodes
are Sources
All-To-One
All-To-All
Figure 2.1: Classication of shortest-path problems
and their solutions. They categorized the literature on shortest-path algorithms by three taxonomic categories and gave an appropriate classiying
schema :
1. By the type of questions being asked about the given network, such as, what is the shortest path from single-node x to singlenode y (Fig. 2.1).
2. By salient features of the input network: whether the network is sparse
or dense, with or without cycles, directed or undirected, with all positiveweight edges or with both positive and negative edges, and so on (Fig. 2.2).
Schema 1.
3. By the underlying techniques used to solve the problem, such as, whether
the solution technique is a labelling procedure of multiplying matrices
(Fig. 2.3).
Note, that the partition classes in all 3 classication rules are not disjoint.
So, one or another problem can belong to the leaf-class "Multiple-Source
Problem" and at the same time to the leaf-class "Algebraically Related Problems" in (Fig. 2.2). I will use this classication scheme to determine a type
of the problems, both an EAP and a MNTP, and a type of the solving techniques for these problems in the following sections.
8
Input Networks
Inherent
Properties
Representations
Adjacency Matrix
Local
Global
Undirected
Without
Negative Arc
With some
Negative Arcs
Acyclic Network
Highway
Networks
Unrestricted
Arc Length
Restricted
Arc Length
Euclidean
Distances
Backward Star
Form
Non-Sparse
Sorted
Forward Star
Form
Uniform Arc
Length
Probabilistic
Arc Length
Forward Star
Form
Sparse
Directed
Deterministic
Arc Length
Arc List
Decomposable
Networks
Grid Networks
Rectangular
Grid Networks
Project
Networks
Grid Graph
Uniform Arc
Length
Figure 2.2: Classication of input networks for shortest-path algorithms
Techniques For Solving
Shortest Path Problems
Preprocessing
Techniques
Path Finding Techniques
Data Permutations
Route Recording and
Reconstructing
Techniques
Updating Techniques
Structural
Transformations
Special Hardware
Techniques
Analog Computer
Techniques
General Purpose
Computer Solution
Node Renumbering
Arc Sorting
Combinatorial Techniques
Algebraic Techniques
Figure 2.3: Classication of techniques for solving shortest-path problems
9
Chapter 3
Itinerary Problems : Formulations
and Common Solutions
A
timetable
is a network composed of nodes (station, bus stops, etc.) and
some elementary connections between them. Each elementary connection is
a train (or bus, etc.)
which starts and arrives at certain nodes and has a
certain departure and arrival time.
e = (s, t, d, a),
d is the departure time at s and a is
the arrival time at t. I will also call s and t the
and the
of e, respectively. A
between two connections e1 = (s1 , t1 , d1 , a1 ) and
e2 = (s2 , t2 , d2 , a2 ) is possible if t1 = s2 and a1 ≤ d2 .
A
or an itinerary between two nodes s and t is a sequence of elementary connections (e1 , . . . , en ), where s is the source node of e1 , t is the
target node of en , and a transfer between each ei and ei+1 is possible.
The time values are elements of a totally ordered set T with a dened
addition operation. As a rule, T consists of integer numbers between 0 and
where
s
and
t
So it can be interpreted as a 4-tuple
are nodes,
source node
transfer
target node
route
1439 and represents the time in minutes after midnight.
The time may
denote one or several successive days which can be integrated into one model
by counting the time modulo 1440 and keeping track of the days [17]. So I
use only one day as a time horizon without loss of generality in this thesis.
A number of important problems on timetable information is described in
[22, 14, 10, 20, 24, 25]. The
earliest arrival problem
and fundamental of them.
Instances of EAP are 3-tuples
is a source node,
t
is a target node, and
10
d
(EAP) is the most basic
(s, t, d),
where
s
is the earliest departure time at
s.
The task consists in nding a route from
s
to
t
which departs from
s
not
earlier than the given earliest departure time and minimizes the dierence
between the arrival time at
t
and the earliest given departure time.
EAP
has a realistic and a simplied version. The realistic version considers the
minimum transfer time at a station.
The transfer time in the simplied
version is assumed to be 0. In this thesis I will only consider the simplied
version of EAP.
Another problem in timetable information is the
transfers problem
station
s
minimum number of
(MNTP). In this case, a query consists of a departure
and an arrival station
t
only. The task is to nd an itinerary that
minimizes the number of train transfers.
3.1
EAP and MNTP as Representatives of Shortest Path Problems
In this section I give a class membership of EAP and MNTP as to the
Schema 1.
According to the rst taxonomy category (see Schema 1) pro-
posed in the forgoing section both EAP and MNTP belong to the class of
one-to-one single-source problems as well as to the class of problems with
the path length as some function on paths.
MNTP however belongs also
to the class of problems with generalized path lengths, which means some
turn penalties. The input networks considered in the connection with EAP
and MNTP are those with Unrestricted Arc Length, very sparse and are
represented commonly as Arc Lists (see Fig. 2.2).
Here is a bibliography survey on the mentioned problem types. SingleSource Problems are probably the most commonly encountered and consist
in the nding of a shortest path from a specied node to another specied
destination node. Algorithms that solve single-source problems are usually
based on the methods proposed by Bellman [3], Dijkstra [12], Ford [15] and
Moore [21].
The most extensive list of roughly 30 references, and a brief
description of each of them can be found in [11].
EAP and MNTP also represent the set of time-dependent shortest-path
problems, where the arc length is assumed to be some function of time. The
problems of this kind were rst mentioned in the work of Cooke and Halsey
and solved in the same way as in the work of Bellman [3] for usual time-
11
j
12:00
9 – 10
10 – 11
11 – 12
u
v
11:00
10:00
9:00 10:00 11:00
Figure 3.1: Trains between stations
i
and
j
i
and the plot of
fij
independent paths. The solution was yielded by an iterative algorithm with
the complexity
O(|V | · |E|).
However, the Cooke and Halsey's algorithm
describes a wide range of problems, since it uses the general notion of the
arc length as a function.
So it does not use individual properties of the
ordinary functions, which can bear a large eld to apply several heuristics.
fij (t) as an arc length function between two nodes
i and j that denotes the minimum arrival time at j by departing not earlier
than time t from the node i(see Fig. 3.1). This function has three signicant
For example, we can dene
properties:
• fij
is piecewise constant
• fij
is monotonic increasing
• f (t) ≥ t
for all
t (f
has non-negative delay)
These three properties are irrelevant and not used in the Cooke-Halsey
algorithm.
The provision for these three properties is the core idea of the
time-dependent approach, which will be presented later in this section. One
should also mention the work of Orda and Rom [23], in which they suggested the shortest-path algorithm for the networks with time-dependent
arc length and with a complexity of
O(|V |2 ).
The algorithm uses a princi-
ple of the Dantzig's Shortest Route Algortihm [9], which fans out from the
source node working out the shortest path to the target node and never having to backtrack. The common approaches, a time-expanded model and a
time-dependent model, use the DIJKSTRA algorithm to obtain the solution,
which bears the complexity
O(|V | log |V | + |E|).
I will give the taxonomy
classication of both models according to Schema 1
the next section.
12
Item 3.
and Fig. 2.3 in
Chapter 4
The Time-Expanded Model
The time-expanded model is based on the following transformation.
Each
e = (s, t, d, a) induces a copy of the source node s
tagged with the departure time stamp d and a copy of the target node t tagged
respectively with the arrival time stamp a. Thus, the initial connections
elementary connection
become the connections between a pair of copies according to their time
stamps.
s of the initial network all its copies will be captured
and ordered ascending their time stamps. Let v1 , . . . , vk be the copies of s in
that order. Then, there is a set of stay-edges (vi , vi+1 ), i = 1, . . . , k − 1, conNext, for each station
necting the two subsequent copies within a station and representing waiting
time at that station between two time events. Thus, given a graph
where
S
is a set of stations and
E
(S, E),
is a set of edges or elementary connections,
the time-expanded model will include as many as
2|E| − |S|
stay-edges.
The example in Fig. 4.1 illustrates the transformation of an initial network
to the time-expanded model. The timetable consists of ve stations and seven
elementary connections between these stations. The time stamps at the edges
represent the departure and arrival time of the given connection.
The route between two nodes consists not only of the elementary connections, but also of some stay-edge connections. It can also
happen that there are many stay-edges belonging to only one station. For
example, the dashed line in Fig. 4.2 shows, that the route between stations 1
and 5 includes two stay-edges at station 3. Hence the number of the edges on
a route depends on the number of the transfers and on the number of initial
Observation 1.
13
1
10-12
4
5
10:00
10:00
11:00
10-13
2
3
9:00
1
9-10
2
3
12:00
12:00
13:00
13:00
15-17
12-14
14:00
11-13
4
13-16
15:00
5
16:00
17:00
Figure 4.1: An initial network
Figure 4.2:
The transformed time-
expanded network
Table 4.1: The size of the time-expanded graph
Initial graph
Number of nodes
Number of edges
|S|
|E|
(S, E)
Time-expanded graph
2|E|
≤ 3|E| − |S| ≤ 3|E|
events as a whole.
The number of nodes in the time-expanded model is equal to the double
number of elementary connections of the initial graph, since each connection
produces a copy of its source and its target nodes. The number of edges in the
time-expanded model includes the elementary connections and the stay-edge
connections (cf. Table 4.1).
14
4.1
EAP with the Time-Expanded Model
The original approach for solving the shortest-path problem is the
Dijkstra
algorithm [12]. Every edge in the time-expanded model has departure and
arrival time stamps. The time dierence between these time stamps can be
attached as the weight to the given edge(see Fig. 4.3). Starting at the rst
copy of the source node, but not earlier than allowed by the earliest departure
time, we nd a shortest path by reaching any copy of the target node [24].
Dijkstra
G = (S, E), the complexity of the
algorithm is
O(|E| + |S| log |S|). According to Table 4.1, for the timetable with |S| stations and |E| elementary connections, the run-time of the
algoritm
applied on the time-expanded model is equal to c(3|E| − |S| + 2|E| log 2|E|),
where c is a constant stemming from the
algorithm.
Given a network
Dijkstra
Dijkstra
1
2
3
4
5
9:00
1
1
10:00
10:00
1
2
2
11:00
2
1
12:00
12:00
1
2
13:00
13:00
1
2
14:00
3
15:00
16:00
2
1
17:00
Figure 4.3: A time-expanded network with weights for EAP
15
4.2
The
MNTP with the Time-Expanded Model
Dijkstra algorithm can be also used for solving MNTP with the time-
expanded model. The edges between copies of dierent stations are assigned a
weight of 1, and stay-edges are assigned a weight of 0(see Fig. 4.4). Starting at
the rst possible copy of a source station, discounting the earliest departure
time, the shortest path to a copy of a target station yields a solution of
MNTP. The complexity of MNTP with the time-expanded model coincides
with the complexity of EAP, since it uses the same algorithm.
It should be remarked that the above described applications of the timeexpanded model refer to the earliest ideas of the time-expanded approach.
Recently, many speed-up techniques for EAP and MNTP have been developed. The extensions and improvements of the time-expanded approach and
shortest-path algorithms are described in [10, 24, 27, 17, 13].
In this pa-
per the new approach for solving EAP and MNTP is only compared to the
original formulations of the time-expanded model and the shortest-path algorithms. The comparison to the newest improvements of the time-expanded
and time-dependent model should be made in future research.
1
2
3
4
5
9:00
0
1
10:00
10:00
1
11:00
0
1
1
0
12:00
12:00
1
13:00
0
13:00
0
0
14:00
1
15:00
1
16:00
0
17:00
Figure 4.4: A time-expanded network with weights for MNTP
16
Chapter 5
The Time-Dependent Model
The time-dependent model [6] is also based on a directed graph
where every edge
e = (i, j) has an associated
as described at the end of Sect. 3.1.
G = (S, E),
fe : T → T
link-traversal function
A path through a time-dependent
s1 , s2, ..., sn of stations in S and a sein T if e = (si , si+1 ) ∈ E is an edge of
graph can be dened as a sequence
quence
S
and
t1 , t2 , ..., tn of
ti+1 = fe (ti ).
time stamps
So if we are looking for the shortest traversal in the
time-dependent network, we should not only pay attention to the arrival
at the destination station, but also to the satisfaction of time constraints
ti+1 = fe (ti ).
EAP
usual
and
A variant of
MNTP
Dijkstra algorithm [12] can be used to solve
in the time-dependent model. The only dierence to the
Dijkstra algorithm consists in nding the edge lengths "on-the-y".
The length of an edge depends on the time in which the particular edge will
be used in the run of
Dijkstra algorithm.
So if we assume that we can
quickly(ecient) evaluate the link-traversal functions of a time-dependent
network, then the time complexity of the time-dependent approach remains
within the complexity class of
5.1
Dijkstra algorithm.
EAP with the Time-Dependent Model
As mentioned above we consider a modication of
solve the Earliest Arrival Problem.
Dijkstra algorithm to
Now we only need to dene the edge
si ∈ S
e = (si , sj ) ∈
lengths "on-the-y" in the following way. If we arrive at some node
at a time moment
t,
and are looking for a length of an edge
17
E,
le (t) = fe (t) − t. This method is correct for
0
(t ≤ t ⇒ f (t) ≤ f (t )), non-negative delay (∀t, f (t) ≥ t) link-
we just calculate it as
monotonic
0
traversal functions. This is based on the same kind of argument as the one
showing
Dijkstra algorithm correct for non-negatively weighted graphs. A
complete proof of correctness can be found in [5].
5.2
MNTP with the Time-Dependent Model
The solution of the Minimum Number of Transfers Problem can be obtained
in the same way as for the Earliest Arrival Problem. It makes sense to dene
all the edge lengths in the time-dependent graph for MNTP constantly equal
1. In this case however the satisfaction of the time constraints provided from
the edge arrivals and departures is lost. Thus, an edge length for an edge
e = (si , sj ) ∈ E by arriving at station si at the moment t will be dened
as follows: le (t) := 1, if the departure time of e is not greater than t and
le (t) := ∞ otherwise. Certainly we may keep records of the arriving times t
at the stations to calculate the link-traversal functions f .
18
Chapter 6
The Edge-Converted Model
In this section I will describe a new model for timetable information. Similar
to the time-expanded approach, I use a transformation of the initial network to obtain a static structure supporting well known algorithms, such
as
Dijkstra or breadth-rst search.
The core idea of the new approach is
to convert the initial elementary connections to nodes. Therefore, I call it
edge-converted approach. The whole transformation routine is listed below:
At rst we take all the stations of the initial network as new
Step 1.
nodes. We call these nodes
type A nodes
(see Fig. 6.1).
Then for every elementary connection
Step 2.
node that gets all four parameters of the edge
these nodes
type B nodes
e
e = (s, t, d, a),
will be created.
a new
We call
(see Fig. 6.2).
Step 3. Now we connect type A nodes to type B nodes according to the
next two rules.
a) There is an outgoing edge from a type A node
v = (s, t, a, d)
if
u
if
t=u
to a type B node
u = s.
b) There is an outgoing edge from a type B node
node
u
v = (s, t, a, d) to a type A
(see Fig. 6.3).
Step 4. Next, we add several edges connecting type B nodes with each
other.
There are four conditions for the existence of an edge between two
type B nodes
a)
u = (su , tu , du , au )
and
v = (sv , tv , dv , av ):
tu = sv
19
Type A
Type A
1
1
1-2
9-10
2
3
1-3
10-12
2
3
2-3
10-13
2-4
11-13
3-5
15-17
2-4
12-14
Type B
4-5
13-16
4
5
4
5
Figure 6.1: A transformation into the Figure 6.2: A transformation into the
edge-converted model : Step 1
edge-converted model : Step 2
1
1-2
9-10
1
1-2
9-10
1-3
10-12
2
3
2
3
2-3
10-13
2-4
11-13
1-3
10-12
2-3
10-13
3-5
15-17
2-4
11-13
2-4
12-14
3-5
15-17
2-4
12-14
4-5
13-16
4
4-5
13-16
5
4
5
Figure 6.3: A transformation into the Figure 6.4: A transformation into the
edge-converted model : Step 3
edge-converted model : Step 4
20
b)
au ≤ d v
c) For all type B nodes
aw ≤ dv ,
then
then
if
sw = su , tw = tu ,
and
if
sw = sv , tw = tv ,
and
du ≥ dw .
d) For all type B nodes
au ≤ d w ,
w = (sw , tw , dw , aw ),
w = (sw , tw , dw , aw ),
aw ≥ au .
The complete edge-converted graph from the example in Fig. 4.1 is depicted in Fig. 6.4.
A route between two nodes (independent of their type) is dened as a
usual path in the edge-converted graph. I start with some initial observations
on the edge-converted graph.
Observation 2.
1. The connections between two type B nodes represent a transfer possibility between two elementary connections in the initial timetable.
2. If there exists a route between two type A nodes u and v, then there
exists a route which only contains type B nodes as intermediate nodes,
i.e., the only type A nodes are the source u and the target v. Thus, the
length of a route is not dependent on the network size, but only on the
number of the necessary transfers (compare with Observation 1).
3. The edge-converted graph has no cycles consisting only of type B nodes.
These observations will be used in the applications below where some
path between two type A nodes only via type B nodes is searched.
Let us estimate the size of the new edge-converted model. Each node has
been induced either by an initial station (type A) or by an initial elementary
connection (type B). So the number of new nodes can be calculated as the
sum of the initial nodes and edges.
The number of new edges cannot be
provided in an explicit form and does not only depend on the number of the
initial edges or nodes but also on the connections' time stamps. Rules c) and
d) from Step 4 in our construction lter out the bad transfer possibilities
from the set of all possible transfers. The remaining edges between type B
nodes represent the good transfer possibilities. Thus, the total number of
edges in the edge-converted graph equals
21
2·#initial edges+#good transfers.
Table 6.1: A comparison of the size of the time-expanded, time-dependent
and edge-converted models
Initial graph/Time-dependent
Time-expanded
Edge-converted
≤ 2kn2
≤ 3kn2 − n
≤ n + kn2
≤ kn3 + 2kn2
≤ 2dn
≤ (3d − 1)n
≤ (d + 1)n
≤ (d2 + 2d)n
Very dense networks
#stations =
n
#elementary connections
≤ kn2
Constant-degree networks
#stations =
n
#elementary connections
≤ dn
Let us calculate an estimation for this number. Given a timetable with
n
n−1 stations in the original
most k elementary connections
stations, each station can be connected at most to
network.
If we assume that there are at
between each pair of the initial stations, then, in the worst case, the edgeconverted model contains
O(kn3 )
edges connecting type B nodes with each
other.
This, however, does not happen in realistic networks. Towards a better
analysis, let us assume that the original network is of
most
d,
i.e., every station has at most
to other stations.
nodes and
≤ 2dn
d
In this case we get
ingoing and
2
≤ dn
d
constant degree
of at
outgoing connections
edges for connecting type B
edges for connecting type A nodes to the type B nodes.
Thus, the total size of the edge-converted graph is linear in the size of the
original network. This is depicted in Table 6.1. As the table shows, regarding
realistic networks, the edge-converted model contains fewer nodes, but more
edges than in the time-expanded model.
A possible drawback of the edge-converted model is that, unlike in the
time-expanded approach, only a xed time horizon can be presently incorporated. Thus, for practical purposes, one has to dene a xed maximal travel
time and adjust the time horizon accordingly to one or several days.
22
6.1
EAP and MNTP with the Edge-Converted
Model
The common approach to solve EAP or MNTP in the time-expanded and
time-dependent approach is to use the
Dijkstra algorithm which consumes
more than linear running time. Two algorithms for EAP and MNTP with
only linear run-time for the edge-converted model will be described below.
Moreover, my algorithms have the advantage of great simplicity as they implement variants of depth-rst search and breadth-rst search, respectively.
6.1.1
EAP with the Edge-Converted Model
The new algorithms include a pre-processing step that has to be done only
(s, t, d) be an EAP query. We need to nd a route connecting the
stations s and t, starting not earlier than at the given time d and providing
the earliest arrival time at t. The main idea of my algorithm below is to use
a usual depth-rst search but starting from the target node t and moving
backwards to the source s. This algorithm solves the EAP if we execute the
once. Let
next pre-processing routine on the edge-converted model:
1. First we delete all the edges constructed in step 3.a) in the section
above. They are redundant for solving the EAP using the next algorithm.
2. Next, given some node
v
of type A or type B in an edge-converted
graph, it has a set of ingoing edges
in this list has a start node
ui
{e1 , . . . , ek }.
Every edge
ei = (ui , v)
of type B, because there are no edges
starting in type A nodes according to the previous step. We sort the
set of ingoing edges for each node
time stamps of their start nodes
v
in descending order by the arrival
ui (see
Fig. 6.5).
Algorithm 1 implements an inverse depth-rst search on an edge-converted
network constructed and pre-processed according to the above mentioned
rules.
and
The algorithm uses a stack
pop(S, u)
S
supporting the operations
which push and pop a node
u
from the top of
computation the algorithm maintains an array
node
During the
route[u] which for each type B
u points towards a subsequent connection.
23
S.
push(S, u)
At the end, the fastest route
1
1-2
9-10
1
1-3
10-12
1
1
2
2
2-3
10-13
1
3
1
2
2-4
12-14
2-4
11-13
3-5
15-17
1
1
2
2
4-5
13-16
1
4
5
Figure 6.5: An edge-converted network pre-processed for EAP. The numbers
on the edges represent the ordering of the ingoing edges
from
with
s to t can
route[s].
be read o by following the pointers in the array, starting
I state the correctness of the algorithm in the following theorem.
Algorithm 1 solves the EAP in the edge-converted model in
Theorem 1.
linear time.
Proof. G
Let
query. Let
be an edge-converted network and let
u1 , . . . , u k
(s, t, d0 )
be an EAP
be the set of predecessors of t, ordered according to the
ui
tree Ti
arrival time stamps of the type B nodes
(in ascending order). Each node
ui
consisting of all nodes which are
is the root of a depth-rst search
(s, t, d0 ) has a solution,
then there exists a type B node vs = (s, v, d, a) such that d ≥ d0 and vs is
contained in one of the trees Ti for some 1 ≤ i ≤ k .
I prove the correctness of Algorithm 1 by induction on the number i.
First note that if s is reached in line 14, then
visited from
ui
in Algorithm 1. If the EAP instance
(vs = route[s], route[route[s]], . . . , ui , t)
describes the unique path from
vs ∈ T1 .
vs
to
t
in
Ti .
In the base case
But then we have found a route from
i = 1,
we have
s to t which arrives at t by the
earliest possible connection in the network, and hence this route is optimal.
24
Algorithm 1 EAP in the edge-converted model
Require: an EAP query
where
G = (V, E)
is an edge-converted network,
and target node, and
1:
2:
3:
(G, s, t, d0 )
d0
v ∈ V do
route[v] ← nil
visited[v] ← false
for all
end for
5:
push(S, t)
while S is not empty do
u ← pop(S)
visited[u] ← true
if u is a type A node then
su ← u
7:
8:
9:
10:
11:
u = (su , tu , du , au )
13:
end if
14:
if
16:
{this only happens if
u = t}
else
12:
15:
are the start
is the earliest departure time
4:
6:
s, t ∈ V
is a type B node
su = s then
route[s] ← u
return route
17:
end if
18:
for all edges
e = (v, u)
(in descending order according to the arrival
22:
a of v ) do
v = (sv , tv , dv , av ) is a type B node
if visited[v] = false and dv ≥ d0 then
route[v] ← u
push(S, v)
23:
end if
time
19:
20:
21:
24:
end for
25:
end while
26:
return
there is no connection between
25
s
and
t
starting after time
d0
Let now
vs ∈ Ti
with
i ≥ 2.
Aiming towards a contradiction, we assume
that Algorithm 1 returns the route via the connections
(vs , . . . , ui ),
but this
is not the optimal solution.
This means that there exists some node
(s, v 0 , d0 , a0 )
and there exists a route
(s, vs0 , . . . , uj , t) which
leads to an earlier arrival at t. As the connections u1 , . . . , uk have been
0
ordered according to their arrival times, we have j < i. But then vs ∈ Tj and
0
Algorithm 1 would have returned the route (s, vs , . . . , uj , t) by the induction
such that
d0 ≥ d0
vs0 =
hypothesis.
Therefore, Algorithm 1 is correct. It runs in linear time, because every
type B node is visited at most once.
In Theorem 1 the time is measured in terms of the input, i.e., in terms of
the edge-converted network. As the size of the edge-converted graph is linear
for constant-degree graphs (cf. Table 6.1), we immediately get:
For constant-degree graphs, Algorithm 1 solves the EAP in
linear time measured in the size of the initial network.
Corollary 2.
In comparison, using
Dijkstra on constant-degree graphs only yields
algorithms with running time
O(n log n).
In real networks, each station only
has a limited number of connections per time interval. Therefore, real networks will usually be close to regular graphs.
6.1.2
MNTP with the Edge-Converted Model
To solve MNTP with the edge-converted model, we can use a breadth-rst
search (see Algorithm 2). Starting at the source node
s,
we nd the route
with the minimum number of transfers by reaching the target node t. Instead
of a stack, Algorithm 2 uses a queue
Q.
The correctness of the algorithm
can be shown by induction on the number of transfers in the optimal route
from
s
to
t.
Thus we get:
Theorem 3.
linear time.
Algorithm 2 solves the MNTP in the edge-converted model in
Again, for regular networks we obtain a linear-time bound in terms of the
original network:
For constant-degree graphs, Algorithm 2 solves the MNTP in
linear time measured in the size of the initial network.
Corollary 4.
26
Algorithm 2 MNTP in the edge-converted model
Require: an MNTP query
where
(G, s, t)
G = (V, E) is an edge-converted network and s, t ∈ V
are the start
and target node
1:
v ∈ V do
route[v] ← nil
visited[v] ← false
for all
2:
3:
4:
end for
5:
if
6:
s=t
then
return
route
7:
end if
8:
enqueue(Q, s)
while Q is not empty do
u ← dequeue(Q)
visited[u] ← true
for all edges e = (u, v) do
if visited[v] = false and v = (sv , tv , d, a)
route[v] ← u
if tv = t then
route[t] ← v
return route
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
end if
19:
enqueue(Q, v)
20:
21:
is a type B node then
end if
end for
22:
end while
23:
return
there is no connection between
27
s
and
t
Chapter 7
Performance Comparison
To test the performance of the Algorithms 1, 2 for EAP and MNTP I implemented the time-expanded, time-dependent and edge-converted models.
The
Dijkstra algorithm with a priority queue was used to solve EAP and
MNTP in the time-expanded and time-dependent models, yielding time complexity
O(n log n).
These algorithms were tested against Algorithms 1 and 2
in the edge-converted model on randomly generated data.
The experiments were run on a PC with an Intel Core2Duo processor
at 1.6 GHz and 2 GB RAM running Windows Vista. The algorithms were
C++
implemented in
compiled with a VC8 compiler at the maximum opti-
mization level.
A rectangular area is used to distribute a set of stations. The stations
are randomly chosen in the area by assigning some
distance
d (u, v)
distance between
between two stations
u and v in the plane.
u
and
v
x and y
coordinates. The
is dened as the Euclidean
The number of elementary connections
is thirty times more than the number of stations. The source and destination
stations of each elementary connection are randomly chosen from the set of
stations.
The time horizon is dened as
between
u
and
v,
departure time at
[0, 1439].
For an elementary connection
the travel time is dened proportionally to
u
d (u, v).
The
is uniformly distributed over the time horizon taking
into account that the arrival time must also fall within the time horizon.
I have conducted three experiments with dierent sizes of the initial network including 100, 1,000 and 10,000 stations respectively. The size of 10,000
stations and 300,000 corresponds to the realistic network size of the railway
28
Table 7.1:
Experimental comparison of EAP and MNTP in the time-
expanded and time-dependent models (using
Dijkstra with priority queue)
and in the edge-converted model (Algorithms 1 and 2)
Initial graph
Time-Dependent
Time-Expanded
Edge-Converted
EAP
MNTP
EAP
MNTP
EAP
MNTP
in sec.
in sec.
in sec.
in sec.
in sec.
in sec.
3000
0.04
0.04
0.06
0.05
0.005
0.02
1000
30000
0.6
0.5
0.8
0.5
0.025
0.05
10000
300000
10
2
13
3
0.25
2
#nodes
#edges
100
network of Germany.
There are 10 queries considered in each experiment.
For EAP, a query consists of a source and target node, which are randomly
dened from the node set and an earliest departure time, that was randomly
dened from the rst third of the time horizon. An MNTP query consists
only of a source and target node, which were dened above. After each experiment the query procession values were avereged. The results are shown
in Table 7.1.
The results clearly show that Algorithm 1 solves EAP considerably faster
than using
Dijkstra
in the time-expanded and time-dependent models,
whereas for MNTP we obtain similar running times.
Instead of using an explicit stack, I implemented Algorithm 1 recursively
which explains the better running time in comparison to Algorithm 2 which
uses a queue.
29
Chapter 8
Conclusion and Future Work
The theoretical results as well as the practical evaluations show that using
the edge-converted model might be an interesting alternative to the known
algorithmic techniques for timetable information. This is mainly due to the
very easy algorithms based on depth-rst and breadth-rst search. However,
the results here provide only a rst basic study of the edge-converted model
and further investigation seems to be necessary. In particular, I would like
to compare the edge-converted model with more sophisticated versions of
the time-expanded approach, which uses a range of speed-up techniques for
Dijkstra [27, 26, 29, 28].
An interesting question for further research is
whether similar speed-up techniques are applicable in the edge-converted
model. For example, one can try to implement an
A∗
search algorithm[19]
in the edge-converted model. This uses information about the geolocation of
the stations and can reduce a search eld only to the trains in the direction of
a given target station. A number of practical evaluations in time-expanded
and time-dependent models conrmed[8, 18] that the use of an
meaningfully improves the running time.
A∗
algorithm
Another eld of interest is the
question how far the edge-converted model can be simplied or reduced: in
particular, if the size of an edge-converted network can achieve a linear size
of an initial network in the general case. Now I have the assumption that
it is possible to obtain an a edge-converted model with
#edges
stations and
3·#edges connections, where #edges is the number of elementary connections
in the initial network. Finally, in future work I would like to test the edgeconverted model on real networks.
30
Bibliography
[1] R. K. Ahuja, T. L. Magnanti, and J. B. Orlin.
Network Flows
. Prentice
Hall, Englewood Clis, New Jersey, 1993.
Dynamic Programming
[2] R. Bellman.
. Princeton University Press, Prince-
ton, 1957.
[3] Richard Bellman. On a routing problem.
matics
Quarterly of Applied Mathe-
, 16(1):8790, 1958.
[4] Olaf Beyersdor and Yevgen Nebesov. Edges as nodes - a new approach
Proc. 9th Workshop on Algorithmic Approaches for Transportation Modeling, Optimization, and Systems (ATMOS), Dagstuhl Research Online Publication Server (DROPS)
to timetable information.
In
, 2009.
[5] Gerth Stølting Brodal and Riko Jacob.
Time-dependent networks as
models to achieve fast exact time-table queries. Technical report, Techical Report ALCOM-FT-TR-01-176, ALCOM-FT, 2001.
[6] Gerth Stølting Brodal and Riko Jacob.
Time-dependent networks as
models to achieve fast exact time-table queries.
Comput. Sci
Electr. Notes Theor.
, 92:315, 2004.
[7] B. A. Carré. An algebra for network routing problems.
Applics
J. Inst. Maths
, 7:273294, 1971.
[8] Ismaïl Chabini and Shan Lan.
Adaptations of the A* algorithm for
the computation of fastest paths in deterministic discrete-time dynamic
networks.
IEEE Transactions on Intelligent Transportation Systems
3(1):6074, 2002.
31
,
[9] G.B. Dantzig. On the shortest route through a network.
Science
Management
, pages 187190, 1960.
[10] Daniel Delling, Thomas Pajor, and Dorothea Wagner. Engineering time-
ATMOS 2008 8th Workshop on Algorithmic Approaches for Transportation Modeling,
Optimization, and Systems
expanded graphs for faster timetable information.
In
, 2008.
[11] N. Deo and C. Pang. Shortest-path algorithms: taxonomy and annotation.
Networks
, 14(2), 1984.
[12] Dijkstra. A note on two problems in connexion with graphs.
Mathematik
Numerische
, 1:269271, 1959.
[13] E.Kohler, R.H.Mohring, and H.Schilling. Acceleration of shortest path
International Workshop
on Experimental and Ecient Algorithms (WEA), LNCS
and constrained shortest path computation. In
, volume 4,
2005.
[14] Fleischer and Skutella. The quickest multicommodity ow problem. In
IPCO: 9th Integer Programming and Combinatorial Optimization Conference
, 2002.
[15] Jr. Ford, L.R.
Network ow theory.
Technical Report P-923, RAND
Corp., Santa Monica, CA, 1956.
[16] A. Frieze.
Quarterly
Minimum paths in directed graphs.
Operational Research
, pages 339346, 1977.
[17] Robert
Geisberger,
Peter
Sanders,
Dominik
Schultes,
and
Daniel
Delling. Contraction hierarchies: Faster and simpler hierarchical routing in road networks.
Workshop, WEA
In
Experimental Algorithms, 7th International
, pages 319333, 2008.
[18] Andrew V. Goldberg and Chris Harrelson. Computing the shortest path:
A search meets graph theory. In
SODA
, pages 156165. SIAM, 2005.
[19] P. E. Hart, N. J. Nilsson, and B. Raphael. A formal basis for the heuristic
determination of minimum cost paths.
netics
, SSC-4 (2):100107, 1968.
32
IEEE Trans. Syst. and Cyber-
[20] Kohler,
Langkau,
and
Skutella.
dependent transit times. In
gorithms
Time-expanded
graphs
for
ow-
ESA: Annual European Symposium on Al-
, 2002.
Proceedings of
an International Symposium on the Theory of Switching, Part II
[21] E. F. Moore.
The shortest path through a maze.
In
, pages
285292. Harvard University Press, Cambridge, Massachusetts, 1959.
[22] Matthias Müller-Hannemann, Frank Schulz, Dorothea Wagner, and
Christos D. Zaroliagis. Timetable information: Models and algorithms.
4359:6790, 2004.
[23] Orda and Rom. Shortest-path and minimum delay algorithms in networks with time-dependent edge-length.
JACM: Journal of the ACM
,
37, 1990.
[24] Pyrga, Schulz, Wagner, and Zaroliagis.
Experimental comparison of
ALENEX: International Workshop on Algorithm Engineering and Experimentation,
LNCS
shortest path approaches for timetable information. In
, 2004.
[25] Evangelia Pyrga, Frank Schulz, Dorothea Wagner, and Christos D. Zaroliagis. Ecient models for timetable information in public transportation systems.
ACM Journal of Experimental Algorithmics
, 12, 2007.
[26] Schulz, Wagner, and Zaroliagis. Using multi-level graphs for timetable
ALENEX: International Workshop
on Algorithm Engineering and Experimentation, LNCS
information in railway systems. In
, 2002.
[27] Frank Schulz, Dorothea Wagner, and Karsten Weihe. Dijkstra's algorithm on-line: An empirical case study from public railroad transport.
ACM Journal of Experimental Algorithmics
, 5, 2000.
[28] Dorothea Wagner and Thomas Willhalm.
Speed-up techniques for
STACS 2007, 24th Annual Symposium
on Theoretical Aspects of Computer Science, Aachen, Germany, February 22-24, 2007, Proceedings
shortest-path computations. In
, volume 4393, pages 2336, 2007.
33
[29] Dorothea Wagner, Thomas Willhalm, and Christos D. Zaroliagis. Geometric containers for ecient shortest-path computation.
of Experimental Algorithmics
, 10, 2005.
34
ACM Journal