A Trichotomy for Regular Trail Queries

Authors Wim Martens , Matthias Niewerth , Tina Trautner

Thumbnail PDF


  • Filesize: 0.55 MB
  • 16 pages

Document Identifiers

Author Details

Wim Martens
  • University of Bayreuth, Germany
Matthias Niewerth
  • University of Bayreuth, Germany
Tina Trautner
  • University of Bayreuth, Germany


We thank the participants of Shonan meeting No. 138 (and Hassan Chafi in particular), who provided significant inspiration for the first paragraph in the Introduction, Jean-Éric Pin for pointing us to positive C_ne-varieties of languages, and Jean-Éric Pin and Luc Segoufin for their help with the proof of Proposition 3.13(b). Furthermore, we want to thank the anonymous reviewers of STACS 2020 for useful comments.

Cite AsGet BibTex

Wim Martens, Matthias Niewerth, and Tina Trautner. A Trichotomy for Regular Trail Queries. In 37th International Symposium on Theoretical Aspects of Computer Science (STACS 2020). Leibniz International Proceedings in Informatics (LIPIcs), Volume 154, pp. 7:1-7:16, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2020)


Regular path queries (RPQs) are an essential component of graph query languages. Such queries consider a regular expression r and a directed edge-labeled graph G and search for paths in G for which the sequence of labels is in the language of r. In order to avoid having to consider infinitely many paths, some database engines restrict such paths to be trails, that is, they only consider paths without repeated edges. In this paper we consider the evaluation problem for RPQs under trail semantics, in the case where the expression is fixed. We show that, in this setting, there exists a trichotomy. More precisely, the complexity of RPQ evaluation divides the regular languages into the finite languages, the class T_tract (for which the problem is tractable), and the rest. Interestingly, the tractable class in the trichotomy is larger than for the trichotomy for simple paths, discovered by Bagan et al. [Bagan et al., 2013]. In addition to this trichotomy result, we also study characterizations of the tractable class, its expressivity, the recognition problem, closure properties, and show how the decision problem can be extended to the enumeration problem, which is relevant to practice.

Subject Classification

ACM Subject Classification
  • Information systems → Query languages for non-relational engines
  • Information systems → Information retrieval query processing
  • Theory of computation → Problems, reductions and completeness
  • Theory of computation → Regular languages
  • Regular languages
  • query languages
  • path queries
  • graph databases
  • databases
  • complexity
  • trails
  • simple paths


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Parosh Aziz Abdulla, Aurore Collomb-Annichini, Ahmed Bouajjani, and Bengt Jonsson. Using forward reachability analysis for verification of lossy channel systems. Formal Methods in System Design, 25(1):39-65, 2004. Google Scholar
  2. Renzo Angles, Marcelo Arenas, Pablo Barceló, Peter A. Boncz, George H. L. Fletcher, Claudio Gutierrez, Tobias Lindaaker, Marcus Paradies, Stefan Plantikow, Juan F. Sequeda, Oskar van Rest, and Hannes Voigt. G-CORE: A core for future graph query languages. In International Conference on Management of Data (SIGMOD), pages 1421-1432, 2018. Google Scholar
  3. Marcelo Arenas, Sebastián Conca, and Jorge Pérez. Counting beyond a yottabyte, or how SPARQL 1.1 property paths will prevent adoption of the standard. In International Conference on World Wide Web (WWW), pages 629-638, 2012. Google Scholar
  4. Esther M. Arkin, Christos H. Papadimitriou, and Mihalis Yannakakis. Modularity of cycles and paths in graphs. J. ACM, 38(2):255-274, 1991. Google Scholar
  5. Guillaume Bagan, Angela Bonifati, and Benoît Groz. A trichotomy for regular simple path queries on graphs. In Symposium on Principles of Database Systems (PODS), pages 261-272, 2013. Google Scholar
  6. Pablo Barceló. Querying graph databases. In Symposium on Principles of Database Systems (PODS), pages 175-188, 2013. Google Scholar
  7. Pablo Barceló, Leonid Libkin, and Juan L. Reutter. Querying graph patterns. In PODS, pages 199-210. ACM, 2011. Google Scholar
  8. Geert Jan Bex, Frank Neven, Thomas Schwentick, and Stijn Vansummeren. Inference of concise regular expressions and dtds. ACM Trans. Database Syst., 35(2):11:1-11:47, 2010. Google Scholar
  9. Angela Bonifati, Wim Martens, and Thomas Tim. Navigating the maze of wikidata query logs. In The Web Conference (WWW). ACM, 2019. To appear. Google Scholar
  10. Angela Bonifati, Wim Martens, and Thomas Timm. An analytical study of large SPARQL query logs. PVLDB, 11(2):149-161, 2017. Google Scholar
  11. Angela Bonifati, Wim Martens, and Thomas Timm. DARQL: deep analysis of SPARQL queries. In WWW (Companion Volume), pages 187-190. ACM, 2018. Google Scholar
  12. Dbpedia. URL: https://wiki.dbpedia.org.
  13. Steven Fortune, John Hopcroft, and James Wyllie. The directed subgraph homeomorphism problem. Theoretical Computer Science (TCS), 10(2):111-121, 1980. Google Scholar
  14. Nadime Francis, Alastair Green, Paolo Guagliardo, Leonid Libkin, Tobias Lindaaker, Victor Marsault, Stefan Plantikow, Mats Rydberg, Petra Selmer, and Andrés Taylor. Cypher: An evolving query language for property graphs. In SIGMOD Conference, pages 1433-1445. ACM, 2018. Google Scholar
  15. Wouter Gelade, Marc Gyssens, and Wim Martens. Regular expressions with counting: Weak versus strong determinism. SIAM J. Comput., 41(1):160-190, 2012. Google Scholar
  16. Leonard H. Haines. On free monoids partially ordered by embedding. Journal of Combinatorial Theory, 6(1):94-98, 1969. Google Scholar
  17. Neil Immerman. Nondeterministic space is closed under complementation. SIAM J. Comput., 17(5):935-938, 1988. Google Scholar
  18. Pierre Jullien. Contribution à l'étude des types d'ordres dispersés. PhD thesis, Universite de Marseille, 1969. Google Scholar
  19. Andrea S. LaPaugh and Christos H. Papadimitriou. The even-path problem for graphs and digraphs. Networks, 14(4):507-513, 1984. Google Scholar
  20. Katja Losemann and Wim Martens. The complexity of regular expressions and property paths in SPARQL. ACM Transactions on Database Systems, 38(4):24:1-24:39, 2013. Google Scholar
  21. Wim Martens, Matthias Niewerth, and Tina Trautner. A trichotomy for regular trail queries. CoRR, abs/1903.00226, 2019. URL: http://arxiv.org/abs/1903.00226.
  22. Wim Martens and Tina Trautner. Evaluation and enumeration problems for regular path queries. In ICDT, volume 98 of LIPIcs, pages 19:1-19:21. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2018. Google Scholar
  23. Alberto O. Mendelzon and Peter T. Wood. Finding regular simple paths in graph databases. SIAM Journal on Computing, 24(6):1235-1258, December 1995. Google Scholar
  24. Harold Marston Morse. Recurrent geodesics on a surface of negative curvature. Transactions of the American Mathematical Society, 22(1):84–100, January 1921. URL: https://doi.org/10.2307/1988844.
  25. Neo4j. URL: https://neo4j.com/.
  26. Cypher query language reference, version 9, mar. 2018. URL: https://github.com/opencypher/openCypher/blob/master/docs/openCypher9.pdf.
  27. Oracle spatial and graph. URL: https://www.oracle.com/database/technologies/spatialandgraph.html.
  28. Yehoshua Perl and Yossi Shiloach. Finding two disjoint paths between two pairs of vertices in a graph. J. ACM, 25(1):1-9, 1978. Google Scholar
  29. Neo4J Petra Selmer. Personal communication. Google Scholar
  30. Jean-Éric Pin. The dot-depth hierarchy, 45 years later. In The Role of Theory in Computer Science, pages 177-202. World Scientific, 2017. Google Scholar
  31. Marcel Paul Schützenberger. On finite monoids having only trivial subgroups. Information and Control, 8(2):190-194, 1965. Google Scholar
  32. Axel Thue. Über unendliche Zeichenreihen. Skrifter udg. af Videnskabs-Selskabet i Christiania : 1. Math.-Naturv. Klasse. Dybwad [in Komm.], 1906. Google Scholar
  33. Tigergraph. URL: https://www.tigergraph.com/.
  34. 1.1 query language. https://www.w3.org/TR/sparql11-query/, 2013. World Wide Web Consortium. URL: https://www.w3.org/TR/sparql11-query/.
  35. Wikidata. URL: https://www.wikidata.org/.
  36. Jin Y. Yen. Finding the k shortest loopless paths in a network. Management Science, 17(11):712-716, 1971. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail