1 Shortest Paths Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij.

Slides:



Advertisements
Similar presentations
Min Cost Flow: Polynomial Algorithms. Overview Recap: Min Cost Flow, Residual Network Potential and Reduced Cost Polynomial Algorithms Approach Capacity.
Advertisements

1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Graphs: MSTs and Shortest Paths David Kauchak cs161 Summer 2009.
October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
1 Shortest Paths Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
Lectures on Network Flows
1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount.
Chapter 7 Maximum Flows: Polynomial Algorithms
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Tirgul 12 Algorithm for Single-Source-Shortest-Paths (s-s-s-p) Problem Application of s-s-s-p for Solving a System of Difference Constraints.
Lecture 19: Shortest Paths Shang-Hua Teng. Weighted Directed Graphs Weight on edges for distance
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Shortest Path Problems
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
1 8-ShortestPaths Shortest Paths in a Graph Fundamental Algorithms.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Shortest Paths Definitions Single Source Algorithms
2-Layer Crossing Minimisation Johan van Rooij. Overview Problem definitions NP-Hardness proof Heuristics & Performance Practical Computation One layer:
Algorithms and Networks
Tirgul 13. Unweighted Graphs Wishful Thinking – you decide to go to work on your sun-tan in ‘ Hatzuk ’ beach in Tel-Aviv. Therefore, you take your swimming.
1 Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
All-Pairs Shortest Paths
Maximum flow Algorithms and Networks. A&N: Maximum flow2 Today Maximum flow problem Variants Applications Briefly: Ford-Fulkerson; min cut max flow theorem.
Dijkstra’s Algorithm Slide Courtesy: Uwash, UT 1.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Greed: Shortest Path s 3 t
Shortest Paths1 C B A E D F
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
1 GRAPHS - ADVANCED APPLICATIONS Minimim Spanning Trees Shortest Path Transitive Closure.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
COSC 3101NJ. Elder Assignment 2 Remarking Assignment 2 Marks y = 0.995x R 2 = Old Mark New Mark.
5/27/03CSE Shortest Paths CSE Algorithms Shortest Paths Problems.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Spring 2015 Lecture 10: Elementary Graph Algorithms
Representing and Using Graphs
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
Graph Algorithms. Definitions and Representation An undirected graph G is a pair (V,E), where V is a finite set of points called vertices and E is a finite.
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
Lecture 16. Shortest Path Algorithms
Introduction to Algorithms Jiafen Liu Sept
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Graphs Part II Lecture 7. Lecture Objectives  Topological Sort  Spanning Tree  Minimum Spanning Tree  Shortest Path.
SPANNING TREES Lecture 21 CS2110 – Fall Nate Foster is out of town. NO 3-4pm office hours today!
Shortest Path Algorithm 2 Prof. Sin-Min Lee Department of Computer Science.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Single Source Shortest Paths Chapter 24 CSc 4520/6520 Fall 2013 Slides adapted from George Bebis, University of Reno, Nevada.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
Lecture 20. Graphs and network models 1. Recap Binary search tree is a special binary tree which is designed to make the search of elements or keys in.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Shortest Paths and Minimum Spanning Trees
Lectures on Network Flows
Algorithms and Networks Hans Bodlaender
Spanning Trees Lecture 21 CS2110 – Fall 2016.
Graphs Lecture 18 CS2110 – Fall 2009.
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Shortest Paths and Minimum Spanning Trees
Algorithms (2IL15) – Lecture 7
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

1 Shortest Paths Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij

2 Shortest path problem(s) Undirected single-pair shortest path problem  Given a graph G=(V,E) and a length function l :E ! R ¸ 0 on the edges, a start vertex s 2 V, and a target vertex t 2 V, find the shortest path from s to t in G.  The length of the path is the sum of the lengths of the edges. Variants:  Directed graphs.  Travel on edges in one direction only, or with different lengths.  More required than a single-pair shortest path.  Single-source, single-target, or all-pairs shortest path problem.  Unit length edges vs a length function.  Positive lengths vs negative lengths, but no negative cycles.  Why no negative cycles?

3 Contents  Applications.  Modelling problems as shortest path problems.  Dijkstra’s algorithm.  Bidirectional search.  A*  Algorithms for variants.  Bellman-Ford  Floyd-Warshall.  Reweighting. (Johnson’s algorithm)  Using the numbers.  Scaling technique. (Gabow’s algorithm)  Bottleneck shortest paths.

4 Notation and basic assumption Notation  |V| = n, |E| = m.  For directed graphs we use A instead of E.  d l (s,t): distance from s to t: length of shortest path from s to t when using edge length function l.  d(s,t): the same, but l is clear from the context.  In single-pair, single-source, and/or single-target variants, s is the source vertex and t is the target vertex. Assumption  d(s,s) = 0: we always assume there is a path with 0 edges from a vertex to itself.

5 APPLICATIONS: MODELLING USING SHORTEST PATH Shortest Paths – Algorithms and Networks

6 Applications  Route planning.  Subroutine in other graph algorithms.  Facility location.  Maximum flow.  Some other examples we will explore further:  Allocating inspection effort on a production line.  Difference constraints.

7 Application 1: Allocating Inspection Efforts on a Production Line  Production line: ordered sequence of n production stages.  Each stage can make an item defect.  Items are inspected at some stages.  When should we inspect to minimize total costs?

8 Solve By Modelling As a Shortest Paths Problem  Production line: ordered sequence of n production stages.  Items are produced in batches of B > 0 items.  Probability that stage i produces a defect item is a i.  Manufacturing cost per item at stage i: p i.  Cost of inspecting at stage j, when last inspection has been done at stage i:  f ij per batch, plus  g ij per item in the batch Where B(i) denotes the expected number of non-defective items after stage i

9 Idea behind model  l (i,j) is the cost of production and inspection from stage i to stage j, assuming we inspect at stage i, and then again at stage j.  Find the shortest path from 0 to n.

10 Application 2: Difference Constraints  Tasks with precedence constraints and running length.  Each task i has:  Time to complete p i > 0.  Some tasks can be started after other tasks have been completed:  Constraint: s j + p j ≤ s i  First task can start at time 0. When can we finish last task?  Longest/shortest paths problem on directed acyclic graphs (see next slides)!

11 Model  Take vertex for each task.  Take special vertex v 0.  Vertex v 0 models time 0.  Arc (v 0, i) for each task vertex i, with length 0.  For each precedence constraint s j + p j s i an arc (j, i) with length p j.  Note: we have a Directed Acyclic Graph (DAG).  If there is a cycle, then the set is infeasible.

12 Long paths give time lower bounds  If there is a path from v 0 to vertex i with length x, then task i cannot start before time x.  Proof with induction...  Optimal: start each task i at time equal to the length of longest path from v 0 to i.  This gives a valid scheme, and it is optimal by the solution.  The longest path problem can be solved in O(n+m) time, as we have a directed acyclic graph.  Transforming to shortest paths problem: multiply all lengths and times by –1.

13 DIJKSTRA’S ALGORITHM AND OPTIMISATIONS Shortest Paths – Algorithms and Networks

14 Basics of single source algorithms  Each vertex v has a variable D[v].  Invariant: d(s,v)  D[v] for all v  Initially: D[s]=0; vs: D[v] =   D[v] is the shortest distance from s to v found thus far.  Update step over edge (u,v):  D[v] = min{ D[v], D[u]+ l (u,v) }.  To compute a shortest path (not only the length), one could maintain pointers to the `previous vertex on the current shortest path’ (sometimes NULL): p(v).  Initially: p(v) = NULL for each v.  Update step becomes:If D[v] > D[u]+ l (u,v) then D[v] = D[u] + l (u,v); p(v) = u; End if; p-values build paths of length D(v). Shortest paths tree! p-values build paths of length D(v). Shortest paths tree!

15 Dijkstra’s algorithm Dijkstra’s Algorithm 1. Initialize: set D[v] =  for all v 2 V. 2. Take priority queue Q, initially containing all vertices. 3. While Q is not empty,  Select vertex v from Q with minimum value D[v].  Update D[u] across all outgoing edges (v,u).  Update the priority queue Q for all such u.  Assumes all lengths are non-negative.  Correctness proof (done in `Algoritmiek’ course).  Note: if all edges have unit-length, then this becomes Breath-First Search.  Priority queue only has priorities 1 and .

16 On Dijkstra’s algorithm  Running time depends on the data structure chosen for the priority queue.  Selection happens at most n times.  Updates happen at most m times. Depending on the data structure used, the running time is:  O(n 2 ): array.  Selection in O(n) time, updates in O(1) time.  O((m + n) log n): Red-black tree (or other), heap.  Selection and updates in O(log n).  O(m + n log n): Fibonacci heaps.  Selection (delete min) in O(log n), update in O(1) time.

17 Optimisation: bidirectional search  For a single pair shortest path problem:  Start a Dijkstra-search from both sides simultaneously.  Analysis needed for more complicated stopping criterion.  Faster in practice.  Combines nicely with another optimisation that we will see next (A*). stst

18 A*  Consider shortest paths in geometric setting.  For example: route planning for cars system.  Standard Dijkstra would explore many paths that are clearly in the wrong direction.  Utrecht to Groningen would look at roads near Den Bosch or even Maastricht.  A* modifies the edge length function used to direct Dijkstra’s algorithm into the right direction.  To do so, we will use a heuristic as a height function.

19 Modifying distances with height functions  Let h:V ! R ¸ 0 be any function to the positive reals.  Define new lengths l h : l h (u,v) = l (u,v) – h(u) + h(v).  Modify distances according to the height h(v) of a vertex v. Lemmas:  For any path P from u to v: l h (P) = l (P) – h(u) + h(v).  For any two vertices u, v: d h (u,v) = d(u,v) – h(u) + h(v).  P is a shortest path from u to v with lengths l, if and only if, it is so with lengths l h.  Height function is often called a potential function.  We will use height functions more often in this lecture!

20 A heuristic for the distance to the target Definitions:  Let h:V ! R ¸ 0 be a heuristic that approximates the distance to target t.  For example, Euclidean distance to target on the plane.  Use h as a height function: l h (u,v) = l (u,v) – h(u) + h(v).  The new distance function measures the deviation from the Euclidean distance to the target.  We call h admissible if:  for each vertex v: h(v) ≤ d(v,t).  We call h consistent if:  For each (u,v) in E: h(u) ≤ l (u,v) + h(v).  Euclidean distance is admissible and consistent.

21 A* algorithm uses an admissible heuristic  We call h admissible if:  For each vertex v: h(v) ≤ d(v,t).  Consequence: never stop too early while running A*.  Consider the unexpanded nodes in the A* algorithm while the shortest path to t has not yet been discovered.  Then: D[t] > d h (s,t) = d(s,t) – h(s).  Let v be the unexpanded node on the shortest path from s to t with D[v] = d h (s,v).  D[v]= d h (s,v) = d(s,v) – h(s) + h(v) ≤ d(s,v) – h(s) + d(v,t) ≤ d(s,t) – h(s) < D[t].  A* is Dijkstra’s algorithm using an admissible heuristic h as height function.  The new distance function measures the deviation from the too optimistic heuristic.  Negative length arcs can be the result.

22 A* and consistent heuristics  In A* arcs/edges in the wrong direction are less frequently used than in standard Dijkstra.  Faster algorithm, but still correct.  We call h consistent if:  For each (u,v) in E: h(u) ≤ l (u,v) + h(v).  Consequence: all new lengths l h (u,v) are non-negative.  If h(t) = 0, then consistent implies admissible.  In practice, a consistent heuristic makes Dijkstra much faster.  Well, the quality of the heuristic matters.  h(v) = 0 for all vertices v is consistent and admissible but useless.  Euclidian distance can be a good heuristic for shortest paths in road networks.

23 ALGORITHMS FOR VARIANTS Shortest Paths – Algorithms and Networks

24 Negative lengths  What if l (u,v) < 0?  What if there are negative cycles reachable from s?  No shortest paths!  Bellman-Ford algorithm:  For instances without negative cycles.  In O(nm) time: single source shortest path problem when there are no negative cycles reachable from s.  Also: detects whether a negative cycle exists.

25 Bellman-Ford Algorithm 1. Initialize: set D[v] =  for all v 2 V. 2. Repeat |V|-1 times:  For every edge (u,v) in E: update across this edge.  D[v] = min{ D[v], D[u]+ l (u,v) }. 3. For every edge (u,v) in E  If D[v] > D[u] + l (u,v) then there exists a negative cycle.  Invariant: If there is no negative cycle reachable from s, then after i runs of main loop, we have:  If there is a shortest path from s to u with at most i edges, then D[u]=d(s,u), for all u.  If there is no negative cycle reachable from s, then every vertex has a shortest path with at most n – 1 edges.  If there is a negative cycle reachable from s, then there will always be an edge where an update step is possible. Clearly: O(nm) time Clearly: O(nm) time

26 Finding a negative cycle in a graph  Reachable from s:  Apply Bellman-Ford, and look back with pointers.  Or: add a vertex s with edges to each vertex in G. G s s

27 All Pairs Shortest Paths: Floyd-Warshall  Dynamic programming: O(n 3 ) (Floyd-Warshall, 1962) 1. Initialised(u,v) = l (u,v) for all (u, v) in E d(u,v) = otherwise 2. For all u in V - For all v in V -For all w in V -d(v,w) = min{ d(v,u) + d(u,w), d(v,w) }  Invariant of the outer loop:  d(v,w) is length of the shortest path from v to w only visiting vertices that have had the role of u in the outer loop.

28 All Pairs Shortest Paths: Johnson’s Algorithm Observation  If all weights are non-negative we can run Dijkstra with each vertex as starting vertex.  This gives O(n 2 log n + nm) time using a Fibonacci heap.  This is faster than O(n 3 ) on sparse graphs.  Johnson: improvement for sparse graphs with reweighting technique:  O(n 2 log n + nm) time.  Works with negative lengths, but no negative cycles.

29 A recap on height functions  Let h:V ! R be any function to the reals.  Define new lengths l h : l h (u,v) = l (u,v) – h(u) + h(v).  Modify distances according to the height h(v) of a vertex v. Lemmas:  For any path P from u to v: l h (P) = l (P) – h(u) + h(v).  For any two vertices u, v: d h (u,v) = d(u,v) – h(u) + h(v).  P is a shortest path from u to v with lengths l, if and only if, it is so with lengths l h. New lemma:  G has a negative-length circuit with lengths l, if and only if, it has a negative-length circuit with lengths l h.

30 What height function h is good?  Look for height function h with  l h (u,v)  0, for all edges (u,v).  If so, we can:  Compute l h (u,v) for all edges.  Run Dijkstra but now with l h (u,v).  Special method to make h with a single-source shortest path problem and using Bellman-Ford.

31 Choosing h 1. Add a new vertex s to the graph. 2. Solving single-source shortest path problem with negative edge lengths: use Bellman-Ford.  If negative cycle detected: stop. 3. Set h(v) = –d(s,v)  Note: for all edges (u,v):  l h (u,v)= l (u,v) – h(u) + h(v) = l (u,v) + d(s,u) – d(s,v)  0 because: d(s,u) + l (u,v)  d(s,v) G 0 s s

32 Johnson’s algorithm 1. Build graph G’ (as shown). 2. Compute with Bellman-Ford d(s,v) for all v. 3. Set l h (u,v) = l (u,v) + d G’ (s,u) – d G’ (s,v) for all (u,v) in A. 4. For all u do:  Use Dijkstra’s algorithm to compute d h (u,v) for all v.  Set d(u,v) = d h (u,v) – d G’ (s,u) + d G’ (s,v). O(n 2 log n + nm) time

33 USING THE NUMBERS Shortest Paths - Algorithms and Networks

34 Using the numbers  Back to the single source shortest paths problem with non- negative distances  Suppose  is an upper bound on the maximum distance from s to a vertex v.  Let L be the largest length of an edge.  Single source shortest path problem is solvable in O(m + ) time.

35 In O(m+) time  Keep array of doubly linked lists: L[0], …, L[],  Maintain that for v with D[v]  ,  v in L[D[v]].  Keep a current minimum .  Invariant: all L[k] with k <  are empty  Run ‘Dijkstra’ while:  Update D[v] from x to y: take v from L[x] (with pointer), and add it to L[y]: O(1) time each.  Extract min: while L[] empty, ++; then take the first element from list L[].  Total time: O(m+)

36 Corollary and extension  Single-source shortest path: in O(m+nL) time.  Take =nL.  Gabow (1985): Single-source shortest path problem can be solved in O(m log R L) time, where:  R = max{2, m/n}.  L: maximum length of edge.  Gabow’s algorithm uses a scaling technique!

37 Gabow’s Algorithm: Main Idea  First, build a scaled instance:  For each edge e set l ’(e) =  l (e) / R .  Recursively, solve the scaled instance and switch to using Dijkstra ‘using the numbers’ if weights are small enough.  R * d l ’’ (s,v) is when we scale back our scaled instance.  We want d(s,v).  What error did we make while rounding?  Another shortest paths instance can be used to compute the error correction terms on the shortest paths!

38 Computing the correction terms through another shortest path problem  Set for each edge (x,y) in E:  Z(x,y) = l (x,y) + R * d l ’ (s,x) - R * d l ’ (s,y)  Works like a height function, so the same shortest paths!  Height function h(x) = - R * d l ’ (s,x)  Z compares the differences in rounding errors from the shortest paths from s to x and y to the weight l (x,y).  Claim: For all vertices v in V:  d(s,v) = d Z (s,v) + R * d l ’ (s,v)  Proof by property of the height function:  d(s,v)= d Z (s,v) + h(s) – h(v) = d Z (s,v) – R * d l ’ (s,s) + R * d l ’ (s,v) (d l ’ (s,s) = 0) = d Z (s,v) + R * d l ’ (s,v)  Thus, we can compute distances for l by computing distances for Z and for l ’.

39 Gabow’s algorithm 1. If L ≤ R, then  solve the problem using the O(m+nR) algorithm (Base case) 2. Else  For each edge e: set l ’(e) =  l (e) / R.  Recursively, compute the distances but with the new length function l ’.  Set for each edge (u,v): Z(u,v) = l (u,v) + R* d l ’ (s,u) – R * d l ’ (s,v).  Compute d Z (s,v) for all v (how? See next slide!)  Compute d(s,v) using: d(s,v) = d Z (s,v) + R * d l ’ (s,v)

40 A property of Z  For each edge (u,v)  E we have:  Z(u,v) = l (u,v) + R* d l ’ (s,u) – R * d l ’ (s,v)  0, because  l (u,v)  R * l ’(u,v)  R * (d l ’ (s,v) – d l ’ (s,u)).  So, a variant of Dijkstra can be used to compute distances for Z.

41 Computing distances for Z  For each vertex v we have: d Z (s,v) ≤ nR for all v reachable from s  Consider a shortest path P for distance function l ’ from s to v.  For each of the less than n edges e on P, l (e) ≤ R + R* l’ (e).  So, d(s,v) ≤ l (P) ≤ nR + R* l ’(P) = nR + R* d l ’ (s,v).  Use that d(s,v) = d Z (s,v) + R * d l ’ (s,v).  So, we can use the O(m+nR) algorithm (Dijkstra with doubly-linked lists) to compute all values d Z (v).

42 Gabow’s algorithm (analysis)  Each recursive step costs O(m) time:  Base case costs O(m+nR) time.  Single source shortest paths for Z costs O(m + nR) time each.  This is both O(m) time as: R = max{2, m/n}.  In each recursive call we solve the problem with L :=  L/R   Without rounding, recursion depth at most log R L.  So, Gabow’s algorithm uses O(m log R L) time.

43 Example a a b b t t s s

44 BOTTLENECK SHORTEST PATH Shortest Paths – Algorithms and Networks

45 Bottleneck shortest path  Given: weighted graph G, weight w(e) for each arc, vertices s, t.  Problem: find a path from s to t such that the maximum weight of an arc on the path is as small as possible.  Or, reverse: such that the minimum weight is as large as possible: maximum capacity path

46 Algorithms  On directed graphs: O((m+n) log m),  Or: O((m+n) log L) with L the maximum absolute value of the weights.  Binary search and DFS.  On undirected graphs: O(m+n) with divide and conquer strategy.

47 Bottleneck shortest paths on undirected graphs  Find the median weight of all weights of edges, say r.  Look to graph G r formed by edges with weight at most r.  If s and t in same connected component of G r, then the bottleneck is at most r: now remove all edges with weight more than r, and repeat (recursion).  If s and t in different connected components of G r : the bottleneck is larger than r. Now, contract all edges with weight at most r, and recurse.  T(m) = O(m) + T(m/2)

48 LARGE SCALE SHORTEST PATHS ALGORITHMS Shortest Paths – Algorithms and Networks

49 Large scale shortest paths algorithms  The world’s road network is huge.  Open street map has: 2,750,000,000 nodes.  Standard (bidirectional) Dijkstra takes too long.  Many-to-many computations are very challenging.  We briefly consider two algorithms.  Contraction Hierarchies.  Partitioning through natural cuts (Microsoft).  Both algorithms have two phases.  Time consuming preprocessing phase.  Very fast shortest paths queries.  My goal: give you a rough idea on these algorithms.  Look up further details if you want to.

50 Contraction hierarchies  Every node gets an extra number: its level of the hierarchy.  In theory: can be the numbers 1,2,...,|V|.  In practice: low numbers are crossings of local roads, high numbers are highway intersections.  We want to run bidirectional Dijkstra (or a variant) such that:  The forward search only considers going ‘up’ in the hierarchy.  The backward search only considers going ‘down’ in the hierarchy. s s t t Level 4 Level 3 Level 2 Level 1 If levels chosen wisely, a lot less options to explore.

51 Shortcuts in contraction hierarchies  We want to run bidirectional Dijkstra (or a variant) such that:  The forward search only considers going ‘up’ in the hierarchy.  The backward search only considers going ‘down’ in the hierarchy.  This will only be correct if we add shortcuts.  Additional edges from lower level nodes to higher level nodes are added as ‘shortcuts’ to preserve correctness.  Example: shortest path from u to v goes through lower level node w: add shortcut from u to v.  Shortcuts are labelled with the shortest paths they bypass. u u Level 2 Level 1 w w Level 3 v v

52 Preprocessing for contraction hierarchies Preprocessing phase:  Assign a level to each node.  For each node, starting from the lowest level nodes upwards:  Consider it’s adjacent nodes of higher level and check whether the shortest path between these two nodes goes through the current node.  If so, add a shortcut edge between the adjacent nodes.  Great way of using preprocessing to accelerate lots of shortest paths computations.  But:  This preprocessing is very expensive on huge graphs.  Resulting graph can have many more edges (space requirement).  If the graph changes locally, lots of recomputation required.

53 Partitioning using natural cuts Observation  Shortest paths from cities in Brabant to cities above the rivers have little options of crossing the rivers.  This is a natural small-cut in the graph.  Many such cuts exist at various levels:  Sea’s, rivers, canals,...  Mountains, hills,...  Country-borders, village borders,...  Etc...

54 Example of natural cuts From: Delling, Goldberg, Razenshteyn, Werneck. Graph Partitioning with Natural Cuts.

55 Using natural cuts  (Large) parts of the graph having a small cut can be replaced by equivalent smaller subgraphs.  Mostly a clique on the boundary vertices.  Can be a different graph also (modelling highways).

56 Computing shortest paths using natural cuts  When computing shortest paths:  For s and t, compute the distance to all partition-boundary vertices of the corresponding partition.  Replace all other partitions by their simplifications.  Graph is much smaller than the original graph.  This idea can be used hierarchically.  First partition at the continent/country level.  Partition each part into smaller parts.  Etc.  Finding good partitions with small natural cuts at the lowest level is easy.  Finding a good hierarchy is difficult.

57 Finding natural cuts Repeat the following process a lot of times:  Pick a random vertex v.  Use breadth first search to find a group of vertices around v.  Stop when we have x vertices in total ! this is the core.  Continue until we have y vertices in total ! this is the ring.  Use max-flow min-cut to compute the min cut between the core and vertices outside the ring.  The resulting cut could be part of natural cut.  After enough repetitions:  We find lots of cuts, creating a lot of islands.  Recombine these islands to proper size partitions.  Recombining the islands to a useful hierarchy is difficult.

58 CONCLUSION Shortest Paths – Algorithms and Networks

59 Summary on Shortest Paths We have treated:  Some examples of applications  Several algorithms for shortest paths  Variants of the problemDijkstra / Floyd-Warshall  Detection of negative cyclesBellman-Ford Algorithm  Reweighting techniqueJohnson’s Algorithm  Scaling techniqueGabow’s Algorithm  A*, bidirectional search  Bottleneck shortest paths  Large scale shortest paths algorithms  Contraction hierarchies  Shortest paths through partitions using natural cuts  Any questions?