learngraphtheory.org

Guest

Sign in to keep your graphs and progress.

Algorithm Selection

Select an algorithm and generate steps to begin visualization

Delta-Stepping Visualizer

Dijkstra, one bucket at a time

Shortest paths with buckets of width Δ: all vertices of a bucket are settled together, light edges inside the bucket, heavy edges once after it

Time: O(V + E + d·L)
Space: O(V + E)
Use Case: Shortest paths on multicore machines and GPUs, graph analytics libraries, road and web graphs
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Δ-Stepping (Parallel Shortest Paths)

Δ-stepping, by Meyer and Sanders in 2003, finds the shortest paths from one vertex when the weights are non-negative, like Dijkstra's algorithm. Dijkstra settles one vertex at a time, always the closest, which leaves nothing to do in parallel. Δ-stepping sorts the vertices into buckets of width Δ by their tentative distance, bucket i holding the distances from iΔ up to (i + 1)Δ, and processes a whole bucket at once. Edges of weight at most Δ are light: they can land back in the same bucket, so a bucket may need several phases. Heavier edges always reach a later bucket and are relaxed only once, when the bucket is final. With Δ = 1 on unit weights the method is breadth-first search level by level, a tiny Δ turns it into Dijkstra and a huge Δ into Bellman–Ford.

How it works

The visualizer picks Δ as the mean edge weight, rounded, but at least the smallest weight, and colours light and heavy edges differently. Each step is one phase: the vertices taken from the current bucket and every distance that drops, written as D ∞ → 5. The panel shows the buckets with their ranges and contents. In the example Δ = 4, with 10 light and 4 heavy edges. Bucket 0 needs two phases, because B and C, reached from A by light edges, land in it again. The heavy edge A–G first sets G to 9, and a light edge from D later lowers it to 7. The run ends with the shortest-path tree in green after 6 phases, where Dijkstra would have needed 9 steps one after another. Negative weights are refused, as for Dijkstra.

Applications

Δ-stepping is the standard parallel single-source shortest path method on multicore machines, GPUs and clusters. The GAP Benchmark Suite uses it as its reference implementation, Galois and GraphBLAS libraries provide it, and Neo4j Graph Data Science runs its shortest paths with delta-stepping. It suits road networks, social graphs and other large graphs where the distances from one source are needed fast: routing, network analysis, centrality computations that start one search per vertex. The choice of Δ trades work for parallelism: a small Δ wastes little work but leaves many sequential buckets, a large Δ gives big parallel phases but relaxes some edges again and again.

Pseudocode

Buckets of width Δ, light edges in phases, heavy edges once per bucket.

DeltaStepping(G, s, Delta):
    d(v) = infinity for all v, d(s) = 0, put s in bucket 0
    while some bucket is non-empty:
        i = the smallest non-empty bucket, R = {}
        while bucket i is non-empty:          // one phase
            S = bucket i, empty it, R = R + S
            relax the light edges (w <= Delta) out of S
        relax the heavy edges (w > Delta) out of R
    return d

relax(v, x):
    if x < d(v): move v to bucket floor(x / Delta), d(v) = x

A light edge out of bucket i can land in bucket i again, so the inner loop repeats until the bucket stays empty. R collects every vertex the bucket held. A heavy edge is longer than Δ and always leads past bucket i, so relaxing it once, after the bucket is final, is enough. All the relaxations of one phase are independent, which is where the parallelism comes from.

Worked example, step by step

The nine-vertex weighted graph loaded on this page, from A.

Example graph: A–B 2, A–C 3, B–C 1, B–D 3, B–E 2, C–E 2, C–F 4, D–G 2, E–G 6, E–H 7, F–H 2, G–I 5, H–I 3, A–G 9. The mean weight 3.64 rounds to Δ = 4: 10 light edges and 4 heavy ones.

  1. Bucket 0, phase 1. Take A. Its light edges give B 2 and C 3, both still below 4, so they land in bucket 0 again.
  2. Bucket 0, phase 2. Take B and C together. D becomes 5, E 4 and F 7. C to B gives 4, no better than 2. Bucket 0 is now empty, so its heavy edges are relaxed: A–G gives G 9.
  3. Bucket 1 [4, 8). Phase 1 takes D, E and F: D–G lowers G from 9 to 7, F–H gives H 9. G is back in bucket 1, so phase 2 takes G, which improves nothing. The heavy edges of D, E, F and G give I 12.
  4. Buckets 2 and 3. Bucket 2 holds H at 9: H–I gives 12, no better. Bucket 3 holds I. Nothing changes any more.

Distances B 2, C 3, D 5, E 4, F 7, G 7, H 9, I 12 after 6 phases. Dijkstra would settle the 9 vertices in 9 sequential steps, Δ-stepping needs 6 rounds, each of which can run in parallel.

Complexity, and where it comes from

Time: O(n + m + d·L) average work · Space: O(n + m)

Meyer and Sanders analysed random weights in [0, 1] with Δ = Θ(1/d), d the largest degree and L the largest shortest-path distance. Each vertex is then reinserted only a constant number of times on average, so the total work stays linear plus d·L, and the L/Δ buckets each take O(log n) parallel phases. On a single core the bucket bookkeeping makes it slower than a good Dijkstra, the gain is in parallel.

When to use Δ-Stepping (Parallel Shortest Paths), and when not to

Single-source shortest paths, sequential and parallel.

AlternativePrefer it whenCost
DijkstraOne core and non-negative weights. Settles one vertex at a time, never relaxes an edge twice.O((n + m) log n)
Bellman–FordNegative weights, or massive parallelism with plenty of spare work. Every round relaxes every edge.O(nm)
Breadth-first searchAll weights equal. It is Δ-stepping with Δ = 1 on unit weights, one level per bucket.O(n + m)

Common pitfalls

  • Picking Δ blindly. A tiny Δ makes one bucket per distance value and loses the parallelism, a huge Δ puts everything in one bucket and relaxes edges over and over like Bellman–Ford. Start near the mean weight, or 1 / d for random weights, and tune.
  • Allowing negative weights. A negative edge can lower the distance of a vertex in a bucket that is already finished. Like Dijkstra, Δ-stepping then returns wrong answers. The visualizer refuses such graphs.
  • Relaxing heavy edges in every phase. Heavy edges only reach later buckets, so relaxing them inside the phase loop wastes work without changing anything. Collect the vertices in R and relax their heavy edges once.

Frequently asked questions

Why can a bucket need several phases?
A light edge may lead to a vertex whose new distance falls into the same bucket, as B and C did in bucket 0. That vertex must be processed before the bucket is final, so the bucket is emptied again in a new phase.
Is it faster than Dijkstra?
On one core usually not. Its advantage is that each phase can be split across many cores or a GPU. On large road and social graphs that turns a long sequence of vertex-by-vertex steps into far fewer parallel rounds.
How does it relate to other algorithms?
With Δ smaller than every weight difference each bucket holds vertices of one distance, as in Dijkstra with a bucket queue (Dial's algorithm). With Δ = 1 on unit weights it is breadth-first search. With Δ = ∞ everything is one bucket and it becomes Bellman–Ford.

Related algorithms: Dijkstra's Algorithm, Bellman-Ford Algorithm, Breadth-First Search, Johnson's Algorithm, Floyd-Warshall Algorithm

Built by Mohammed Islam HadjoudjWork with me

An example graph: you can change it, or start blank.

Zoom Controls

30%
Nodes: 9
Edges: 14