A Labeling Approach to Incremental Cycle Detection

Edith Cohen, Amos Fiat, Haim Kaplan, Liam RodittyarXiv 2013 · arXiv

Abstract

This paper presents a novel randomized labeling technique for the incremental cycle detection problem in directed graphs. By assigning recursive labels to vertices based on random ranks, we provide a unified framework that matches state-of-the-art complexity bounds while facilitating distributed implementations. Our approach leverages local message passing and lexicographical pruning to maintain Directed Acyclic Graph (DAG) properties efficiently under edge insertions.

Introduction

Maintaining the acyclic property of a directed graph as new edges are added—the incremental cycle detection problem—is critical in various domains, including compiler pointer analysis and circuit simulation. While static cycle detection is straightforward using Depth-First Search (DFS), performing a full search for every edge insertion is computationally expensive for large-scale dynamic graphs. Recent algorithmic breakthroughs have reduced the amortized cost of these updates, but often at the expense of simplicity and parallelizability. We propose a "Recursive Labeling" method that simplifies these complex structures into a local, rank-based system.

Methodology: Recursive Labeling

The core of our approach is the construction of labels that act as a weak topological order. The algorithm proceeds as follows:

  1. Random Ranking: A subset of vertices is randomly selected and assigned unique ranks. This subset serves as the foundation for structural sketches.
  2. Label Generation: For each vertex $u$, a label is defined as a sequence of vertices. The first element is the minimum rank vertex capable of reaching $u$. Subsequent elements are determined by finding the minimum rank vertex reachable from the previous element that also reaches $u$.
  3. Two-Way Search and Pruning: Upon the insertion of an edge $(u, v)$, the algorithm performs a simultaneous backward search from $u$ and forward search from $v$. The labels are used to prune the search space: if a vertex's label indicates that a path cannot exist based on the lexicographical ordering, that branch of the search is terminated early.
  4. Incremental Updates: If no cycle is detected, the labels of affected nodes are updated recursively.
Example of a DAG with a subset of vertices assigned random ranks (red numbers), which are used to generate recursive labels for pruning.

This methodology is particularly well-suited for distributed systems because label updates and cycle detection only require communication between immediate neighbors, avoiding the need for global synchronization.

Theoretical Insights

Our labeling scheme unifies several existing specialized algorithms. By tuning a single probability parameter $q$ (the density of ranked vertices), we can interpolate between different performance regimes. The technique is inspired by transitive closure estimation methods, specifically the work of Edith Cohen. We demonstrate that the "sketches" used for size estimation contain sufficient structural information to maintain a DAG. A key property is that labels are lexicographically descending along any path; any violation of this property during a search immediately identifies a potential cycle or allows for pruning.

Results and Complexity

The proposed algorithm achieves performance parity with the best-known theoretical bounds:

  • Sparse Graphs: Total time complexity of $O(m \cdot n^{2/3} \text{ poly-log } n)$.
  • Dense Graphs: Tunable to $O(n^2 \text{ poly-log } n)$.
  • Overhead: Labels have an expected length of $O(\log n)$, minimizing storage requirements.
  • Distributed Efficiency: Message complexity in synchronized distributed environments matches the centralized time bounds.

Conclusion and Future Work

Recursive labeling provides a robust, randomized framework for incremental cycle detection. While the current results are within a logarithmic factor of the state-of-the-art deterministic algorithms, they offer significant advantages in terms of implementation simplicity and distributed applicability. Future work will focus on extending these bounds to asynchronous distributed models and exploring deterministic variants of the ranking system to provide worst-case guarantees for mission-critical applications.

Summary updated

Abstract

In the \emph{incremental cycle detection} problem arcs are added to a directed acyclic graph and the algorithm has to report if the new arc closes a cycle. One seeks to minimize the total time to process the entire sequence of arc insertions, or until a cycle appears. In a recent breakthrough, Bender, Fineman, Gilbert and Tarjan \cite{BeFiGiTa11} presented two different algorithms, with time complexity $O(n^2 \log n)$ and $O(m \cdot \min \{m^{1/2}, n^{2/3} \})$, respectively. In this paper we introduce a new technique for incremental cycle detection that allows us to obtain both bounds (up to a logarithmic factor). Furthermore, our approach seems more amiable for distributed implementation.
BibTeX
@misc{cohen2013labeling,
  author = {Edith Cohen and Amos Fiat and Haim Kaplan and Liam Roditty},
  title = {{A Labeling Approach to Incremental Cycle Detection}},
  year = {2013},
  eprint = {1310.8381},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1310.8381},
}
Figure