Parallel single-source shortest path algorithm

Last updated

A central problem in algorithmic graph theory is the shortest path problem. One of the generalizations of the shortest path problem is known as the single-source-shortest-paths (SSSP) problem, which consists of finding the shortest paths from a source vertex to all other vertices in the graph. There are classical sequential algorithms which solve this problem, such as Dijkstra's algorithm. In this article, however, we present two parallel algorithms solving this problem.

Contents

Another variation of the problem is the all-pairs-shortest-paths (APSP) problem, which also has parallel approaches: Parallel all-pairs shortest path algorithm.

Problem definition

Let be a directed graph with nodes and edges. Let be a distinguished vertex (called "source") and be a function assigning a non-negative real-valued weight to each edge. The goal of the single-source-shortest-paths problem is to compute, for every vertex reachable from , the weight of a minimum-weight path from Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): s to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): v, denoted by and abbreviated . The weight of a path is the sum of the weights of its edges. We set if is unreachable from . [1]

Sequential shortest path algorithms commonly apply iterative labeling methods based on maintaining a tentative distance for all nodes; is always or the weight of some path from Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): s to Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): v and hence an upper bound on Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): \operatorname{dist}(v). Tentative distances are improved by performing edge relaxations, i.e., for an edge the algorithm sets . [1]

For all parallel algorithms we will assume a PRAM model with concurrent reads and concurrent writes.

Delta stepping algorithm

The delta stepping algorithm is a label-correcting algorithm, which means the tentative distance of a vertex can be corrected several times via edge relaxations until the last step of the algorithm, when all tentative distances are fixed.

The algorithm maintains eligible nodes with tentative distances in an array of buckets each of which represents a distance range of size . During each phase, the algorithm removes all nodes of the first nonempty bucket and relaxes all outgoing edges of weight at most . Edges of a higher weight are only relaxed after their respective starting nodes are surely settled. [1] The parameter is a positive real number that is also called the "step width" or "bucket width". [1]

Parallelism is obtained by concurrently removing all nodes of the first nonempty bucket and relaxing their outgoing light edges in a single phase. If a node has been removed from the current bucket with non-final distance value then, in some subsequent phase, will eventually be reinserted into , and the outgoing light edges of will be re-relaxed. The remaining heavy edges emanating from all nodes that have been removed from so far are relaxed once and for all when finally remains empty. Subsequently, the algorithm searches for the next nonempty bucket and proceeds as described above. [1]

The maximum shortest path weight for the source node is defined as , abbreviated Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): L. [1] Also, the size of a path is defined to be the number of edges on the path.

We distinguish light edges from heavy edges, where light edges have weight at most and heavy edges have weight bigger than .

Following is the delta stepping algorithm in pseudocode:

1  foreachdo 2  Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle relax(s, 0)};                                                    (*Insert source node with distance 0*) 3  whileFailed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle \lnot isEmpty(B)}do                           (*A phase: Some queued nodes left (a)*) 4                            (*Smallest nonempty bucket (b)*) 5                                                      (*No nodes deleted for bucket B[i] yet*) 6      whiledo                     (*New phase (c)*) 7                                     (*Create requests for light edges (d)*) 8                                                     (*Remember deleted nodes (e)*) 9                                                   (*Current bucket empty*) 10                                               (*Do relaxations, nodes may (re)enter B[i] (f)*) 11                                       (*Create requests for heavy edges (g)*) 12     Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle relaxRequests(Req)}                                          (*Relaxations will not refill B[i] (h)*) 13 14 function:set of Request 15     return 16 17 procedure 18     foreachdo 19 20 procedure                                             (*Insert or move w in B if *) 21     ifthen 22                               (*If in, remove from old bucket*) 23                                          (*Insert into new bucket*) 24         Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle \operatorname{tent}(w):=x      }

Example

Example graph Delta stepping example graph.png
Example graph

Following is a step by step description of the algorithm execution for a small example graph. The source vertex is the vertex A and is equal to 3.

At the beginning of the algorithm, all vertices except for the source vertex A have infinite tentative distances.

Bucket Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle B[0]} has range , bucket has range and bucket has range .

The bucket contains the vertex A. All other buckets are empty.

NodeABCDEFG
Tentative distance0

The algorithm relaxes all light edges incident to , which are the edges connecting A to B, G and E.

The vertices B,G and E are inserted into bucket . Since is still empty, the heavy edge connecting A to D is also relaxed.

NodeABCDEFG
Tentative distance03533

Now the light edges incident to are relaxed. The vertex C is inserted into bucket . Since now is empty, the heavy edge connecting E to F can be relaxed.

NodeABCDEFG
Tentative distance0365383

On the next step, the bucket Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle B[2]} is examined, but doesn't lead to any modifications to the tentative distances.

The algorithm terminates.

Runtime

As mentioned earlier, is the maximum shortest path weight.

Let us call a path with total weight at most and without edge repetitions a -path.

Let denote the set of all node pairs Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle \langle u,v \rangle} connected by some -path and let . Similarly, define as the set of triples such that and is a light edge and let .

The sequential delta-stepping algorithm needs at most operations. A simple parallelization runs in time . [1]

If we take for graphs with maximum degree and random edge weights uniformly distributed in , the sequential version of the algorithm needs total average-case time and a simple parallelization takes on average . [1]

Graph 500

The third computational kernel of the Graph 500 benchmark runs a single-source shortest path computation. [2] The reference implementation of the Graph 500 benchmark uses the delta stepping algorithm for this computation.

Radius stepping algorithm

For the radius stepping algorithm, we must assume that our graph is undirected.

The input to the algorithm is a weighted, undirected graph, a source vertex, and a target radius value for every vertex, given as a function . [3] The algorithm visits vertices in increasing distance from the source Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): s. On each step , the Radius-Stepping increments the radius centered at from to , and settles all vertices in the annulus . [3]

Following is the radius stepping algorithm in pseudocode:

Input: A graph , vertex radii , and a source node Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): s.     Output: The graph distances Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle \delta(\cdot)} from .  1  ,   2  foreachdo, , Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle i \leftarrow 1}  3  whiledo  4        5      repeat     6          foreachFailed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle u \in V\setminus S_{i-1}} s.t do  7              foreachdo  8                    9      until no  was updated  10       11       12 return

For all , define to be the neighbor set of S. During the execution of standard breadth-first search or Dijkstra's algorithm, the frontier is the neighbor set of all visited vertices. [3]

In the Radius-Stepping algorithm, a new round distance is decided on each round with the goal of bounding the number of substeps. The algorithm takes a radius Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle r(v)} for each vertex and selects a on step by taking the minimum over all in the frontier (Line 4).

Lines 5-9 then run the Bellman-Ford substeps until all vertices with radius less than Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): d_{i} are settled. Vertices within Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle d_i } are then added to the visited set Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): {\displaystyle S_i }. [3]

Example

Example graph Delta stepping example graph.png
Example graph

Following is a step by step description of the algorithm execution for a small example graph. The source vertex is the vertex A and the radius of every vertex is equal to 1.

At the beginning of the algorithm, all vertices except for the source vertex A have infinite tentative distances, denoted by in the pseudocode.

All neighbors of A are relaxed and .

NodeABCDEFG
Tentative distance03533

The variable is chosen to be equal to 4 and the neighbors of the vertices B, E and G are relaxed.

NodeABCDEFG
Tentative distance0365383

The variable is chosen to be equal to 6 and no values are changed. .

The variable Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "http://localhost:6011/en.wikipedia.org/v1/":): d_{3} is chosen to be equal to 9 and no values are changed. .

The algorithm terminates.

Runtime

After a preprocessing phase, the radius stepping algorithm can solve the SSSP problem in work and depth, for . In addition, the preprocessing phase takes work and depth, or work and depth. [3]

Related Research Articles

<span class="mw-page-title-main">Dijkstra's algorithm</span> Graph search algorithm

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a weighted graph, which may represent, for example, road networks. It was conceived by computer scientist Edsger W. Dijkstra in 1956 and published three years later.

<span class="mw-page-title-main">Bellman–Ford algorithm</span> Algorithm for finding the shortest paths in graphs

The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph. It is slower than Dijkstra's algorithm for the same problem, but more versatile, as it is capable of handling graphs in which some of the edge weights are negative numbers. The algorithm was first proposed by Alfonso Shimbel (1955), but is instead named after Richard Bellman and Lester Ford Jr., who published it in 1958 and 1956, respectively. Edward F. Moore also published a variation of the algorithm in 1959, and for this reason it is also sometimes called the Bellman–Ford–Moore algorithm.

In computer science, the Floyd–Warshall algorithm is an algorithm for finding shortest paths in a directed weighted graph with positive or negative edge weights. A single execution of the algorithm will find the lengths of shortest paths between all pairs of vertices. Although it does not return details of the paths themselves, it is possible to reconstruct the paths with simple modifications to the algorithm. Versions of the algorithm can also be used for finding the transitive closure of a relation , or widest paths between all pairs of vertices in a weighted graph.

<span class="mw-page-title-main">Maximum flow problem</span> Computational problem in graph theory

In optimization theory, maximum flow problems involve finding a feasible flow through a flow network that obtains the maximum possible flow rate.

<span class="mw-page-title-main">Graph coloring</span> Methodic assignment of colors to elements of a graph

In graph theory, graph coloring is a special case of graph labeling; it is an assignment of labels traditionally called "colors" to elements of a graph subject to certain constraints. In its simplest form, it is a way of coloring the vertices of a graph such that no two adjacent vertices are of the same color; this is called a vertex coloring. Similarly, an edge coloring assigns a color to each edge so that no two adjacent edges are of the same color, and a face coloring of a planar graph assigns a color to each face or region so that no two faces that share a boundary have the same color.

In computer science, a topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering. For instance, the vertices of the graph may represent tasks to be performed, and the edges may represent constraints that one task must be performed before another; in this application, a topological ordering is just a valid sequence for the tasks. Precisely, a topological sort is a graph traversal in which each node v is visited only after all its dependencies are visited. A topological ordering is possible if and only if the graph has no directed cycles, that is, if it is a directed acyclic graph (DAG). Any DAG has at least one topological ordering, and algorithms are known for constructing a topological ordering of any DAG in linear time. Topological sorting has many applications especially in ranking problems such as feedback arc set. Topological sorting is possible even when the DAG has disconnected components.

Johnson's algorithm is a way to find the shortest paths between all pairs of vertices in an edge-weighted directed graph. It allows some of the edge weights to be negative numbers, but no negative-weight cycles may exist. It works by using the Bellman–Ford algorithm to compute a transformation of the input graph that removes all negative weights, allowing Dijkstra's algorithm to be used on the transformed graph. It is named after Donald B. Johnson, who first published the technique in 1977.

<span class="mw-page-title-main">Maximal independent set</span> Independent set which is not a subset of any other independent set

In graph theory, a maximal independent set (MIS) or maximal stable set is an independent set that is not a subset of any other independent set. In other words, there is no vertex outside the independent set that may join it because it is maximal with respect to the independent set property.

The Hungarian method is a combinatorial optimization algorithm that solves the assignment problem in polynomial time and which anticipated later primal–dual methods. It was developed and published in 1955 by Harold Kuhn, who gave the name "Hungarian method" because the algorithm was largely based on the earlier works of two Hungarian mathematicians: Dénes Kőnig and Jenő Egerváry.

In graph theory, reachability refers to the ability to get from one vertex to another within a graph. A vertex can reach a vertex if there exists a sequence of adjacent vertices which starts with and ends with .

In computer science, the Hopcroft–Karp algorithm is an algorithm that takes a bipartite graph as input and produces a maximum-cardinality matching as output — a set of as many edges as possible with the property that no two edges share an endpoint. It runs in time in the worst case, where is set of edges in the graph, is set of vertices of the graph, and it is assumed that . In the case of dense graphs the time bound becomes , and for sparse random graphs it runs in time with high probability.

In statistics, single-linkage clustering is one of several methods of hierarchical clustering. It is based on grouping clusters in bottom-up fashion, at each step combining two clusters that contain the closest pair of elements not yet belonging to the same cluster as each other.

In graph theory, the planar separator theorem is a form of isoperimetric inequality for planar graphs, that states that any planar graph can be split into smaller pieces by removing a small number of vertices. Specifically, the removal of vertices from an n-vertex graph can partition the graph into disjoint subgraphs each of which has at most vertices.

Dinic's algorithm or Dinitz's algorithm is a strongly polynomial algorithm for computing the maximum flow in a flow network, conceived in 1970 by Israeli computer scientist Yefim (Chaim) A. Dinitz. The algorithm runs in time and is similar to the Edmonds–Karp algorithm, which runs in time, in that it uses shortest augmenting paths. The introduction of the concepts of the level graph and blocking flow enable Dinic's algorithm to achieve its performance.

In theoretical computer science and network routing, Suurballe's algorithm is an algorithm for finding two disjoint paths in a nonnegatively-weighted directed graph, so that both paths connect the same pair of vertices and have minimum total length. The algorithm was conceived by John W. Suurballe and published in 1974. The main idea of Suurballe's algorithm is to use Dijkstra's algorithm to find one path, to modify the weights of the graph edges, and then to run Dijkstra's algorithm a second time. The output of the algorithm is formed by combining these two paths, discarding edges that are traversed in opposite directions by the paths, and using the remaining edges to form the two paths to return as the output. The modification to the weights is similar to the weight modification in Johnson's algorithm, and preserves the non-negativity of the weights while allowing the second instance of Dijkstra's algorithm to find the correct second path.

In computer science, the method of contraction hierarchies is a speed-up technique for finding the shortest-path in a graph. The most intuitive applications are car-navigation systems: a user wants to drive from to using the quickest possible route. The metric optimized here is the travel time. Intersections are represented by vertices, the road sections connecting them by edges. The edge weights represent the time it takes to drive along this segment of the road. A path from to is a sequence of edges ; the shortest path is the one with the minimal sum of edge weights among all possible paths. The shortest path in a graph can be computed using Dijkstra's algorithm but, given that road networks consist of tens of millions of vertices, this is impractical. Contraction hierarchies is a speed-up method optimized to exploit properties of graphs representing road networks. The speed-up is achieved by creating shortcuts in a preprocessing phase which are then used during a shortest-path query to skip over "unimportant" vertices. This is based on the observation that road networks are highly hierarchical. Some intersections, for example highway junctions, are "more important" and higher up in the hierarchy than for example a junction leading into a dead end. Shortcuts can be used to save the precomputed distance between two important junctions such that the algorithm doesn't have to consider the full path between these junctions at query time. Contraction hierarchies do not know about which roads humans consider "important", but they are provided with the graph as input and are able to assign importance to vertices using heuristics.

The stretched grid method (SGM) is a numerical technique for finding approximate solutions of various mathematical and engineering problems that can be related to an elastic grid behavior. In particular, meteorologists use the stretched grid method for weather prediction and engineers use the stretched grid method to design tents and other tensile structures.

The Shortest Path Faster Algorithm (SPFA) is an improvement of the Bellman–Ford algorithm which computes single-source shortest paths in a weighted directed graph. The algorithm is believed to work well on random sparse graphs and is particularly suitable for graphs that contain negative-weight edges. However, the worst-case complexity of SPFA is the same as that of Bellman–Ford, so for graphs with nonnegative edge weights Dijkstra's algorithm is preferred. The SPFA algorithm was first published by Edward F. Moore in 1959, as a generalization of breadth first search; SPFA is Moore's “Algorithm D.” The name, “Shortest Path Faster Algorithm (SPFA),” was given by FanDing Duan, a Chinese researcher who rediscovered the algorithm in 1994.

In coding theory, Zemor's algorithm, designed and developed by Gilles Zemor, is a recursive low-complexity approach to code construction. It is an improvement over the algorithm of Sipser and Spielman.

<span class="mw-page-title-main">Stoer–Wagner algorithm</span>

In graph theory, the Stoer–Wagner algorithm is a recursive algorithm to solve the minimum cut problem in undirected weighted graphs with non-negative weights. It was proposed by Mechthild Stoer and Frank Wagner in 1995. The essential idea of this algorithm is to shrink the graph by merging the most intensive vertices, until the graph only contains two combined vertex sets. At each phase, the algorithm finds the minimum - cut for two vertices and chosen at its will. Then the algorithm shrinks the edge between and to search for non - cuts. The minimum cut found in all phases will be the minimum weighted cut of the graph.

References

  1. 1 2 3 4 5 6 7 8 Meyer, U.; Sanders, P. (2003-10-01). "Δ-stepping: a parallelizable shortest path algorithm". Journal of Algorithms. 1998 European Symposium on Algorithms. 49 (1): 114–152. doi: 10.1016/S0196-6774(03)00076-2 . ISSN   0196-6774.
  2. "Graph 500". 9 March 2017.
  3. 1 2 3 4 5 Blelloch, Guy E.; Gu, Yan; Sun, Yihan; Tangwongsan, Kanat (2016). "Parallel Shortest Paths Using Radius Stepping". Proceedings of the 28th ACM Symposium on Parallelism in Algorithms and Architectures. New York, New York, USA: ACM Press. pp. 443–454. doi: 10.1145/2935764.2935765 . ISBN   978-1-4503-4210-0.