Regular Expression Matching on billion-nodes Graphs

Hongzhi Wang, Jiabao Han, Bin Shao, Jianzhong LiarXiv 2019

Abstract

In many applications, it is necessary to retrieve pairs of vertices with the path between them satisfying certain constraints, since regular expression is a powerful tool to describe patterns of a sequence. To meet such requirements, in this paper, we define regular expression (RE) query on graphs to use regular expression to represent the constraints between vertices. To process RE queries on large graphs such as social networks, we propose the RE query processing method with the index size sublinear to the graph size. Considering that large graphs may be randomly distributed in multiple machines, the parallel RE processing algorithms are presented without the assumption of graph distribution. To achieve high efficiency for complex RE query processing, we develop cost-based query optimization strategies with only a small size statistical information which is suitable for querying large graphs. Comprehensive experimental results show that this approach scales well for large graphs.

Introduction

Modern graph-based applications, ranging from social network analysis to knowledge base navigation, frequently require identifying vertex pairs connected by paths that follow specific patterns. Regular expressions (RE) offer a natural and powerful language for defining these constraints. However, performing full-featured RE matching—incorporating concatenation, alternatives (|), and transitive closures (+)—on massive graphs with billions of nodes remains a significant computational challenge.

Existing approaches typically suffer from two limitations: incomplete feature support or reliance on heavy structural indices that do not scale. This paper presents a distributed, traversal-based framework that overcomes these hurdles, enabling complex RE queries on billion-node graphs in just a few seconds.

Methodology

The proposed system avoids the memory bottlenecks of traditional structural indices by utilizing a lightweight label-based index and a sophisticated three-tiered processing pipeline.

Query Planning and Physical Implementation

Queries are first parsed into a logical plan of operators. These are then mapped to physical operators designed for high-performance traversal.

  • Logical Operators: The system decomposes infix REs into postfix expressions, identifying core operations like concatenation and closure.
  • Physical Operators: Operators such as Load, Neighbor, and ClosureLink are implemented to perform efficient graph traversals. In distributed settings, the system utilizes the Microsoft Graph Engine, employing batching primitives (BatchGetNeighbor, BatchAddLink) to minimize network overhead.
The data graph structure used to demonstrate the connectivity and labeling required for RE matching.

Cost-Based Optimization

The efficiency of RE matching is highly sensitive to the order and direction of traversal. To address this, the authors developed a Dynamic Programming (DP) optimizer. By using graph-size-independent statistics—such as label frequency and average neighbor counts—the optimizer estimates the cost of various execution plans and selects the one that minimizes intermediate result sets.

Intermediate result sets generated by the physical operators during the execution of a regular expression query.

Experimental Evaluation

The framework was evaluated using the Freebase knowledge base (83M nodes) and synthetic RMAT graphs (up to 1B nodes).

  • Scalability: On a billion-node graph, complex RE queries typically finished in under 2 seconds. The system demonstrated sublinear scaling, proving its viability for massive datasets.
  • Optimizer Performance: The cost-based optimizer proved essential; optimized plans were often orders of magnitude faster than average random plans, closely matching theoretical lower bounds.
  • Distributed Efficiency: The system showed significant speedups when scaled across multiple machines, though gains eventually tapered due to cluster maintenance overhead.

Conclusion

This work demonstrates that traversal-based RE matching, when paired with a robust cost-based optimizer, can scale to billion-node graphs without the need for prohibitive structural indexing. Future research will focus on expanding wildcard support within transitive closures and extending these techniques to general subgraph isomorphism problems.

Summary updated

BibTeX
@misc{wang2019regular,
  author = {Hongzhi Wang and Jiabao Han and Bin Shao and Jianzhong Li},
  title = {{Regular Expression Matching on billion-nodes Graphs}},
  year = {2019},
  eprint = {1904.11653},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1904.11653},
}
Figure