Incremental topological ordering with Bernhard Haeupler, Sid Sen Two problems on digraphs: Cycle detection Topological ordering: a total order O such that.

Slides:



Advertisements
Similar presentations
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
Advertisements

Single Source Shortest Paths
Graphs COP Graphs  Train Lines Gainesville OcalaDeltona Daytona Melbourne Lakeland Tampa Orlando.
Dynamic Graph Algorithms - I
Online Topological Ordering Siddhartha Sen, COS /20/2007.
Chapter 5 Shortest Paths: Label-Correcting Algorithms
Topological Sort and Hashing
Graph Algorithms: Topological Sort The topological sorting problem: given a directed, acyclic graph G = (V, E), find a linear ordering of the vertices.
1 Theory I Algorithm Design and Analysis (10 - Shortest paths in graphs) T. Lauer.
Theory of Computing Lecture 6 MAS 714 Hartmut Klauck.
A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,
More Graph Algorithms Minimum Spanning Trees, Shortest Path Algorithms.
Chapter 10: Iterative Improvement The Maximum Flow Problem The Design and Analysis of Algorithms.
Graphs CS-240/341. Graphs Used for representing many-to-many relationships –can take two forms directed (digraph) - a finite set of elements called vertices.
Discussion #36 Spanning Trees
1 Sadna in Algorithms Haim Kaplan and Svetlana Olonetsky Tel Aviv University, fall 07/08.
1 On Dynamic Shortest Paths Problems Liam Roditty Uri Zwick Tel Aviv University ESA 2004.
I/O-Algorithms Lars Arge Spring 2009 March 3, 2009.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
COS 423 Lecture 9 Shortest Paths II ©Robert E. Tarjan 2011.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Mergeable Trees1 Mergeable Trees Mergeable Trees Robert E. Tarjan Princeton University and HP Labs Joint work with Loukas Georgiadis, Haim Kaplan, Nira.
Chapter 9: Graphs Spanning Trees Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Review of Graphs A graph is composed of edges E and vertices V that link the nodes together. A graph G is often denoted G=(V,E) where V is the set of vertices.
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
Graphs CS 400/600 – Data Structures. Graphs2 Graphs  Used to represent all kinds of problems Networks and routing State diagrams Flow and capacity.
9/10/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 8 Greedy Graph.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
1 WEEK 9-10 Graphs II Unweighted Shortest Paths Dijkstra’s Algorithm Graphs with negative costs Acyclic Graphs Izmir University of Economics.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Graph (II) Shortest path, Minimum spanning tree GGuy
I/O-Efficient Graph Algorithms Norbert Zeh Duke University EEF Summer School on Massive Data Sets Århus, Denmark June 26 – July 1, 2002.
Chapter 2 Graph Algorithms.
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
ADT Table and Heap Ellen Walker CPSC 201 Data Structures Hiram College.
Representing and Using Graphs
Algorithm Course Dr. Aref Rashad February Algorithms Course..... Dr. Aref Rashad Part: 6 Shortest Path Algorithms.
An Optimal Cache-Oblivious Priority Queue and Its Applications in Graph Algorithms By Arge, Bender, Demaine, Holland-Minkley, Munro Presented by Adam Sheffer.
Symbol Tables and Search Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Spanning Trees CSIT 402 Data Structures II 1. 2 Two Algorithms Prim: (build tree incrementally) – Pick lower cost edge connected to known (incomplete)
© 2004 Goodrich, Tamasia Recall: Digraphs A digraph is a graph whose edges are all directed Short for “directed graph” Applications one-way streets flights.
Minimum Spanning Trees Featuring Disjoint Sets HKOI Training 2006 Liu Chi Man (cx) 25 Mar 2006.
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.
CS 61B Data Structures and Programming Methodology Aug 5, 2008 David Sun.
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
1 Fat heaps (K & Tarjan 96). 2 Goal Want to achieve the performance of Fibonnaci heaps but on the worst case. Why ? Theoretical curiosity and some applications.
Minimum Spanning Trees CSE 373 Data Structures Lecture 21.
A dynamic algorithm for topologically sorting directed acyclic graphs David J. Pearce and Paul H.J. Kelly Imperial College, London, UK
Graphs Upon completion you will be able to:
Graph Representations And Traversals. Graphs Graph : – Set of Vertices (Nodes) – Set of Edges connecting vertices (u, v) : edge connecting Origin: u Destination:
CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path.
1 GRAPHS – Definitions A graph G = (V, E) consists of –a set of vertices, V, and –a set of edges, E, where each edge is a pair (v,w) s.t. v,w  V Vertices.
Breadth-First Search (BFS)
Lecture 11 Graph Algorithms
Introduction to Algorithms
ליאור שפירא, חיים קפלן וחברים
Graph Algorithms Using Depth First Search
Short paths and spanning trees
CSE 373 Data Structures and Algorithms
3.4 Push-Relabel(Preflow-Push) Maximum Flow Alg.
Improved dynamic reachability algorithms for directed graphs
Binary Search Trees.
Minimum Spanning Trees
Graph Algorithms: Shortest Path
CSE 417: Algorithms and Computational Complexity
CSE 373: Data Structures and Algorithms
Lecture 11 Graph Algorithms
Presentation transcript:

Incremental topological ordering with Bernhard Haeupler, Sid Sen Two problems on digraphs: Cycle detection Topological ordering: a total order O such that v  w  O(v) < O(w)

Incremental topological ordering A digraph is acyclic if it has at least one topological ordering Static: O(n + m) time, n = # vertices, m = # arcs Assume m ≥ n (simplicity)

Dynamic: on-line, incremental Start with vertex set, no arcs Add one arc at a time Maintain a topological order Report a cycle as soon as one is created

How to maintain ordering? 1-1 mapping: V  {1,2,…,n} via 1 or 2 arrays (inverse?) Dynamic ordered list query: v < w ? update:delete v insert v (before or after) w O(1) time per operation (Dietz, Sleator 1987; Bender, Cole, Demaine, Farach-Colton, Zito 2002) a, b, c, d, e, f, g, h move c after f

Adding an arc Given an existing order, how to handle a new arc v  w? If v < w: do nothing If w < v: search for a cycle or a set of vertices to reorder to restore topological order Affected region: all vertices x : w ≤ x ≤ v

Adding an arc Search forward from w, but not from vertices > v Vertex states during search: U = unlabeled L = labeled, initially {w} S = scanned w v x

Adding an arc scan(x): for x  y if y = v stop (cycle) if y < v and y  U add y to L while L ≠ Ø: delete some x from L, scan(x), add x to S reorder: move S after v (in order)

Adding an arc Running time? Count related pairs: some paths contain more than one type vertex, vertex pairs – arc, vertex pairs – nm arc, arc pairs – One-way search: x  y traversed  v, x  y newly related  O(m) amortized time per arc addition; O(nm) total (vs. O(m 2 )) Marchetti-Spaccamela, Nanni, Rohnert 1996

Two-way (bidirectional) search Forward from w, backward from v concurrently When to stop searching? When to pay for a search step? w v w v ? ?

Two-way (bidirectional) search Stop when  x with: no forward labeled vertices < x no backward labeled vertices > x Reorder: Move forward scanned vertices (≠ x) after x Move backward scanned vertices (≠ x) before x

w v x z  U vw x z

How to pay? Traverse arcs in pairs: x  y forward, z  u backward allowed if x < u Adding v  w relates x  y, z  u (unless cycle) Search time = O(1) per arc traversal + overhead k traversal steps  k 2 /4 new related arc pairs (out of ) k ≤ m 1/2  O(m 1/2 ) time per arc addition k > m 1/2  (km 1/2 )/4 new pairs   k = O(m 3/2 )  O(m 1/2 ) amortized per arc addition

How to implement? Ordered search: Scan smallest forward labeled vertex or largest backward labeled vertex Stop when next forward vertex > next backward vertex  All forward traversed arcs form pairs with all backward traversed arcs But: need a heap (priority queue) for: F = forward labeled vertices R = backward labeled vertices Logarithmic (?) overhead

History of two-way search method Idea: Alpern, Hoover, Rosen, Sweeney, Zadeck 1990 Incremental bound (per arc addition) Katriel, Bodlaender 2005 O(min{m 3/2 logn, m 3/2 + n 2 logn}) Liu, Chao 2007 O(m 3/2 + mn 1/2 logn) Kavitha, Mathew 2007 O(m 3/2 + nm 1/2 logn) Improvable, but… All bounds for m arc additions

Avoid heaps? Can we eliminate the heap altogether? Get O(m 1/2 ) per arc amortized time? Balanced safe search Split:F = A ∪ B R = C ∪ D Choose x  A, u  C If x < u, traverse x  y, z  u If x > u, bypass x (move to B) or u (move to D) Which? What if A or C is empty? bypassed (temporarily)

Soft threshold Maintain a tentative threshold t, initially w or v If x > u, bypass x if x > t, u if u < t (if both, choose one) if A is empty, replace A by B, choose new t uniformly at random from A (or median) Similarly if C is empty  Amortized O(1) bypassed vertices per search step (expected or worst-case)  O(1) overhead per search step  O(m 1/2 ) amortized time per arc addition

forward vertex backward vertex vw unreached vertex l,sl,s h scanned vertex (v,w)(v,w) A = {w}, B = {}, D = {}, C = {v} abcdef sl

s vw l h s A = {}, B = {b,d}, D = {}, C = {c,e} abcdef forward vertex backward vertex unreached vertex scanned vertex l,sl,sl

vw h ls A = {}, B = {d}, D = {c}, C = {} abcdef forward vertex backward vertex unreached vertex scanned vertex h,s h s

vw h ls A = {}, B = {}, D = {c}, C = {} abcdef forward vertex backward vertex unreached vertex scanned vertex s

vws YX abcef forward vertex backward vertex unreached vertex scanned vertex

vwsafbce forward vertex backward vertex unreached vertex scanned vertex

Lower bounds  (n logn) vertex reorderings for any algorithm Ramalingam and Reps 1994  (n 2 ) vertex reorderings if order = 1-1 mapping reordering only within affected region  (nm) vertex reorderings if reordering only within affected region Dense case O(n 2.75 ) Ajwani, Friedrich, Meyer 2006 Õ(n 2.5 ) Liu, Chao 2007 O(n 2.5 ) Kavitha, Mathew 2007