Expressive Path Queries on Graph with Data

Pablo Barceló, Gaëlle Fontaine, Anthony Widjaja Lin

This paper, "Expressive Path Queries on Graphs with Data," explores the fundamental trade-off between how much a graph query language can say and how fast a computer can execute those queries. Specifically, it focuses on "data graphs"—networks where nodes not only have connections but also store data values (like a social network where nodes are people with "age" attributes).

TL;DR

The authors prove that the highly expressive "Walk Logic" (WL) is computationally impractical due to non-elementary data complexity. To solve this, they propose Register Logic (RL), a new framework that captures complex graph properties like Hamiltonicity and bipartiteness while maintaining elementary complexity, offering a more viable path for querying modern data-rich networks.

What Problem Does This Paper Address?

Standard graph query languages, like Conjunctive Regular Path Queries (CRPQs), are excellent at navigating topology (e.g., "find a path from A to B via 'friend' edges"). However, they struggle to incorporate the data values stored at the nodes. For example, a query like "find a path where every person is the same age" is difficult for traditional languages.

Two recent attempts to fix this were Walk Logic (WL) and Regular Expressions with Memory (REM).

  • WL is very powerful but its exact computational cost was unknown.
  • REM is efficient but "blind" to branching structures and cannot compare data values across different paths.

The authors set out to determine the true complexity of WL and to design a new language that bridges the gap between the efficiency of REM and the power of WL.

Methods

The paper employs rigorous complexity analysis and logical formalisms:

  1. Complexity Proofs: The authors use reductions from Turing machine runs. To prove WL is non-elementary, they show how to encode $k$-exponentially bounded runs of a Turing machine into WL formulas and data graphs.
  2. Language Design: They introduce Register Logic (RL). RL extends REM by adding Boolean combinations (AND, OR, NOT) and existential quantification over nodes, paths, and—crucially—register assignments. This allows the logic to "remember" a data value from one path and compare it to a value found on a completely different path.
  3. Model Checking: They evaluate the complexity of RL using Ehrenfeucht-Fraïssé games (a tool from model theory) and alternating Turing machines to establish upper and lower bounds.
  4. Fragment Analysis: They investigate subsets of RL, such as the positive fragment ($RL^+$) and a version with a branching operator ($NRL^+$), to find versions of the language that are particularly efficient for large databases (tractable data complexity).

Key Insights and Ideas

  • The WL "Nonelementary" Trap: The most significant theoretical finding is that WL is "nonelementary." In computational terms, this means the time required to answer a query grows as a tower of exponentials ($2^{2^{2...}}$) based on the size of the query. This holds even for simple formulas, effectively ruling out WL for practical use.
  • Encoding Configurations: To prove these bounds, the authors developed clever ways to encode binary counters and Turing machine configurations into graph structures.
Figure 1: A graph construction used to encode Turing machine configurations for the complexity proof.
  • Incomparability: Interestingly, RL and WL are "incomparable." There are things RL can express that WL cannot (like certain counting properties), and vice versa.
  • The Power of Nesting: The authors show that by adding a "nesting" or branching operator (similar to what is found in XPath), they can create a language ($NRL^+$) that is more expressive than REM but still runs in NLOGSPACE data complexity, making it highly suitable for real-world database applications.

Key Results

  • Walk Logic is Impractical: The evaluation problem for WL is proven to be non-elementary in data complexity.
  • Register Logic is Elementary: RL evaluation is EXPSPACE-complete in combined complexity and PSPACE-complete in data complexity. While still heavy, this is a massive improvement over "nonelementary."
  • Tractable Fragments: The authors identified the $NRL^+$ fragment, which is NLOGSPACE in data complexity. This means it can be evaluated very efficiently on large graphs while still being able to handle complex branching queries that REM cannot.
  • Expressive Reach: RL is shown to be powerful enough to express classic graph theory problems like Hamiltonicity (finding a path that visits every node exactly once) and Bipartiteness.

Limitations and Future Work

  • Theoretical Nature: The paper is purely theoretical. While it establishes complexity classes, it does not provide an empirical implementation or benchmark against existing graph databases like Neo4j.
  • Open Questions on WL: The authors note that it is still unknown if WL can express bipartiteness, an open question from previous literature.
  • Language Comparisons: Further work is needed to compare RL with other powerful extensions like ECRPQ¬ to see which provides the best balance for specific industry use cases.

Summary updated

BibTeX
@inproceedings{barcelo2013expressive,
  author = {Pablo Barceló and Gaëlle Fontaine and Anthony Widjaja Lin},
  title = {{Expressive Path Queries on Graph with Data}},
  booktitle = {LPAR},
  year = {2013},
  url = {https://openreview.net/forum?id=ofmObTKJDLg},
}
Figure