Professional Documents
Culture Documents
Optimization of Landmark Preprocessing With Multicore Systems
Optimization of Landmark Preprocessing With Multicore Systems
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 102
Abstract—Determining a shortest path between two given nodes in a directed graph is a common task which is traditionally solved using
Dijkstra’s algorithm [1]. There are many techniques available to speedup the Dijkstra’s algorithm while guaranteeing the optimality of the solu-
tion. Almost all of the speedup techniques have a substantial amount of parallelism that can be exploited to decrease its running time. The
main focus of the work is to implement landmark technique and to identify the segment of the code in landmark preprocessing which can be
parallelized to obtain better speedup. The results are compared and analyzed for better performance improvements.
Index Terms— Dijkstra’s Algorithm, Graph Theory, parallel programming, running time, speed-up
—————————— ——————————
1 INTRODUCTION
A directed simple graph G is a pair (V, E), where paths in a directed graph with nonnegative edge weights
V is the set of nodes / vertices and E V V is a set of is that of Dijkstra’s algorithm[1]. Dijkstra’s algorithm im-
edges, where an edge is an ordered pair of nodes of the plemented with Fibonacci heaps is still the fastest known
form (u, v) such that u , v V . Usually the number of algorithm for the general case of arbitrary nonnegative
nodes V is denoted by n and the number of edges E is edge lengths, taking O ( m n log n) worst-case time. For
denoted by m. A path in graph G is a sequence of nodes special cases (eg. undirected graphs, integral or uniformly
( u ,..., u ) so that (u , u ) E for all 1 i k . A distributed edge weights), better algorithms are known.
path 1 in which
k i 1 a cycle or cyclic path.
iis called
u u
1 edge
Given the k weights l : E R , the length of
2 RELATED WORK
the path P (u ,..., u ) is the sum of the lengths of its
edges l ( P ) : 1 k Computing shortest paths between nodes in a given di-
1 i k l ( ui , ui 1 ) . For any two nodes
s , t V , a shortest s-t path is a path of minimal length rected graph is classically solved by Dijkstra’s algorithm.
with u s and u t . The distance d ( s , t ) between s But besides Dijkstra’s algorithm there are many recent
and t is1 the length kof the shortest path s-t. A layout of a algorithms that solve variants and special cases of the
graph G (V , E ) is a function L : V R 2 that assigns shortest-path problem with better running time. Typical-
each node a position in R 2 . A graph is called sparse if ly, such improvements of Dijkstra’s algorithm cannot be
m O (n ) . proved to be asymptotically faster than the original algo-
A. Shortest Path Problem rithm, and, in this sense are heuristics. However, it can be
Let G = (V, E) be a directed graph whose edges empirically shown that they indeed improve the running
are weighted by a function w : E R . The weights are time drastically for many realistic data sets. The speedup
interpreted as the edges’ lengths in the sense that the techniques namely Bidirectional search[2], Goal directed
length of a path is the sum of the weights of its edges. The search[3], Multilevel search[4],[5], Shortest path contain-
single-source single-target (SSST) shortest-path problem ers[6] are validated to give better improvements over
consists in finding a path of minimum length from a giv- Dijkstra. The combination of the above mentioned spee-
en source s V to a given target t V . The problem is dup techniques are discussed in [7]. Parallelizing the
only well defined for all pairs, if G does not contain nega- speedup techniques is discussed in [8]. Highway node
tive cycles. In the presence of negative weights, but not routing is parallelized to obtain better speedup.
negative cycles, it is possible, using Johnson’s algorithm,
to convert in O(nm n 2 log n) time the original edge A* SEARCH AND LANDMARKS
weights w : E R to non-negative edge weights A new shortest path algorithm that uses A*
w : E R0 that result in the same shortest paths. search in combination with a new graph‐theoretic lower‐
Hence, it can be safely assumed that the edge weights are bounding technique based on landmarks and the triangle
non-negative. It can also be assumed that for all pairs inequality is explained[7]. The algorithm computes op‐
( s, t ) V V , the shortest path from s to t is unique. timal shortest paths and works on any directed graph.
The classical algorithm for computing shortest
Experimental results show that the new technique outper‐
forms A* search with Euclidean bounds, by a wide mar‐
————————————————
F.A. Author is with Department of Computer Science & Engineering,
gin on road networks [7].
Pondicherry Engineering College, Pondicherry -605014, India. It is noted in [7] that to find a shortest path with
S.B. Author is with Perunthalaivar Kamarajar Institute of Engineering & 1,000 vertices on a graph with 3,000,000 vertices, the algo‐
Technolgy, Karaikal, Pondicherry, India
rithm typically scans only 10,000 vertices, which is a tiny
fraction of the total number of vertices.
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 8, AUGUST 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 103
imized.
2.3.1 Potential Function For road graphs and other geometric graphs,
A potential function is a function, from vertices having a landmark geometrically lying behind the desti‐
to reals. Given a potential function π, the reduced cost of nation tends to give good bounds. Consider a map or a
an edge is defined as follows graph drawing on the plane where graph and geometric
l ( v , w ) l ( v , w ) ( v ) ( w ) (2.1) distances are strongly correlated. The graph does not
need to be planar; for example, road networks are not
Suppose l is replaced by l then for any two ver‐
planar. A simple landmark selection algorithm in this case
tices x and y, the length of any x‐y path changes by the works as follows. First a vertex c closest to the centre of
same amount ( y ) ( x ) . Thus a path is a shortest path the embedding is found. The embedding is divided into k
with respect to l iff it is a shortest path with respect to l pie slice sectors centred at c, each containing approx‐
imately the same number of vertices. For each sector, a
and the two problems are equivalent. vertex is selected that is farthest away from the centre. To
Note that, π is feasible if l is nonnegative for avoid having two landmarks close to each other, if sector
A is processed and sector B is being processed such that
all arcs. It is well known that if (t ) 0 and π is feasible,
the landmark for A is close to the border of A and B, the
then for any v, (v ) is a lower bound on the distance
vertices of B close to the border are skipped. This is re‐
from v to t. It is to be noted that ferred to as planar landmark selection.
Lemma 2.1 If and are feasible potential With the landmarks selected, the distance be‐
1 2
tween the other vertices and the landmarks can be uti‐
functions, then p max( , ) is feasible.
1 2 lized for obtaining estimates on the distance to the target.
Feasible potential functions can be combined by
taking the minimum, or, the average of feasible potential 2.4 OPENMP
functions. The maximum is used in particular to combine OpenMP is an Application Programming Inter‐
feasible lower bound functions in order to get one that face (API) [9] for portable shared memory parallel pro‐
any vertex is at least as high as each original function. gramming. The API allows an incremental approach to
2.3.2 A* Search parallelize an existing code, so that portions of a program
Consider the problem of looking for a path from can be parallelized in successive steps. This is a marked
s to t and assume that a function : V R exists such difference between OpenMP and other parallel pro‐
t
gramming paradigms where the entire program must be
that (v ) gives an estimate on the distance from v to t.
t converted in one step.
A* search is an algorithm that works like Dijkstra’s algo‐ 2.4.1 Fork and Join Model of OpenMP
rithm, except that at each step it selects a labelled vertex v Multithreaded programs can be written in differ‐
with the smallest value k ( v ) d ( v ) ( v ) to scan ent ways that allows complex interaction between
s t threads. OpenMP provides a simple structured approach
next. It is easy to verify that A* search is equivalent to
to multithreaded programming. OpenMP supports a
Dijkstra’s algorithm on the graph with length function
fork‐join programming model as shown in Fig. 1.
l .
In this approach, the program starts as a
t
single thread of execution. Whenever an OpenMP parallel
2.3.3 Landmark Selection construct is encountered by a thread while it is executing
Finding good landmarks is critical for the overall the program, it creates a team of threads (this is the fork),
performance of lower‐bounding algorithms. Let k denote becomes the master of the team, and collaborates with the
the number of landmarks. The simplest way of selecting other members of the team to execute the code enclosed
landmarks is to select k landmark vertices at random. by the construct. At the end of the construct, only the
Better choices are possible. original thread continues; all others terminate (this is the
One greedy landmark selection algorithm works join). Each portion of code enclosed by a parallel con‐
as follows. A start vertex is selected and a vertex that is struct is called a parallel region.
farthest away from it is found. Add the new vertex to the
set of landmarks. Proceed in iterations, at each of the ite‐
ration finding a vertex that is farthest away from the cur‐
rent set of landmarks and adding the vertex to the set.
This algorithm can be viewed as a quick approximation to
the problem of selecting a set of k vertices so that the min‐
imum distance between a pair of selected vertices is max‐
JOURNAL OF COMPUTING, VOLUME 2, ISSUE 8, AUGUST 2010, ISSN 2151-9617
HTTPS://SITES.GOOGLE.COM/SITE/JOURNALOFCOMPUTING/
WWW.JOURNALOFCOMPUTING.ORG 104
17000 127500 0.765 0.129 7747 0.0899 9177 11000 19344 0.0208 0.00505 416 0.00445 434
18000 133200 0.886 0.107 5814 0.105 10380 12000 21166 0.0226 0.00555 488 0.00515 488
19000 142500 0.878 0.108 6139 0.0905 8535 13000 22999 0.0248 0.0058 494 0.0053 493
20000 161000 0.969 0.149 8147 0.132 12390 14000 24869 0.0269 0.0063 540 0.00565 548
21000 155400 1.03 0.152 8313 0.125 11826 15000 26698 0.0282 0.0068 536 0.00635 550
22000 167200 1.06 0.194 11341 0.124 10558 16000 28555 0.0304 0.00725 554 0.00655 554
23000 154100 1.04 0.189 11749 0.104 10420 17000 30399 0.0358 0.00945 656 0.0087 656
24000 166800 1.07 0.168 10432 0.119 11639 18000 32251 0.0383 0.00955 580 0.00905 594
25000 186250 1.27 0.187 10245 0.137 11857 19000 34111 0.0412 0.01 652 0.0093 679
TABLE 3
ANALYSIS OF PARALLELISED PREPROCESSING IN LANDMARKS
(RANDOM GRAPHS)
Preprocess Preprocess
Vertex
Edge Count Time [Land‐ Time with
Count
marks] (s) parallelism (s)
REFERENCES