Evaluating Graph Queries Using Semantic Treewidth

Authors Cristina Feier, Tomasz Gogacz, Filip Murlak

Thumbnail PDF


  • Filesize: 0.74 MB
  • 20 pages

Document Identifiers

Author Details

Cristina Feier
  • University of Warsaw, Poland
Tomasz Gogacz
  • University of Warsaw, Poland
Filip Murlak
  • University of Warsaw, Poland

Cite AsGet BibTex

Cristina Feier, Tomasz Gogacz, and Filip Murlak. Evaluating Graph Queries Using Semantic Treewidth. In 27th International Conference on Database Theory (ICDT 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 290, pp. 22:1-22:20, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)


Unions of conjunctive two-way regular path queries (UC2RPQs) are a common abstraction of query languages for graph databases, much like unions of conjunctive queries (UCQs) in the relational case. As in the case of UCQs, their evaluation is NP-complete in combined complexity. Semantic tree-width, i.e. the minimal treewidth of equivalent queries, has been proposed as a candidate criterion to characterize fixed-parameter tractability of UC2RPQs. It was recently shown how to decide the semantic tree-width of a UC2RPQ, by constructing the best under-approximation of a given treewidth, in the form of a UC2RPQ of size doubly exponential in the size of the original query. This leads to an fpt algorithm for evaluating UC2RPQs of semantic TW k which runs in time doubly exponential in the size of the parameter, i.e. in the UC2RPQ. Here we describe a more efficient fpt algorithm for evaluating UC2RPQs of semantic treewidth k which runs in time singly exponential in the size of the parameter. We do this by a careful construction of a witness query which, while still being doubly exponential, can be represented as a Datalog program of bounded width and singly exponential size.

Subject Classification

ACM Subject Classification
  • Theory of computation → Regular languages
  • Information systems → Query languages
  • Theory of computation → Semantics and reasoning
  • Theory of computation → Automated reasoning
  • Theory of computation → Complexity theory and logic
  • conjunctive two-way regular path queries
  • fixed-parameter tractable evaluation
  • semantic treewidth
  • Datalog encoding
  • optimization


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


  1. Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases. Addison-Wesley, 1995. Google Scholar
  2. Foto Afrati and Francesca Toni. Chain queries expressible by linear datalog programs. Databases and Logic Programming, pages 49-58, dec 1997. Google Scholar
  3. Renzo Angles and Claudio Gutiérrez. Survey of graph database models. ACM Computing Surveys (CSUR), 40(1):1-39, feb 2008. URL: https://doi.org/10.1145/1322432.1322433.
  4. Pablo Barceló, Leonid Libkin, Anthony W. Lin, and Peter T. Wood. Expressive languages for path queries over graph-structured data. ACM Trans. Database Syst., 37(4), 2012. URL: https://doi.org/10.1145/2389241.2389250.
  5. Pablo Barceló, Jorge Pérez, and Juan L. Reutter. Relative expressiveness of nested regular expressions. In Proc. of the 6th Alberto Mendelzon International Workshop on Foundations of Data Management, June 27-30, 2012, volume 866, pages 180-195. CEUR-WS.org, 2012. URL: https://ceur-ws.org/Vol-866/paper13.pdf.
  6. Pablo Barceló, Miguel Romero, and Moshe Y. Vardi. Semantic acyclicity on graph databases. SIAM Journal on Computing, 45(4):1339-1376, 2016. URL: https://doi.org/10.1137/15M1034714.
  7. Pablo Barceló. Querying graph databases. In Proc. of the 32nd Symposium on Principles of Database Systems, pages 175-188. ACM, 2013. URL: https://doi.org/10.1145/2463664.2465216.
  8. Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Moshe Y. Vardi. Containment of conjunctive regular path queries with inverse. In Proc. of the Seventh International Conference on Principles of Knowledge Representation and Reasoning, KR'00, pages 176-185, 2000. Google Scholar
  9. Chandra Chekuri and Anand Rajaraman. Conjunctive query containment revisited. Theor. Comput. Sci., 239(2):211-229, 2000. URL: https://doi.org/10.1016/S0304-3975(99)00220-0.
  10. Hubie Chen, Georg Gottlob, Matthias Lanzinger, and Reinhard Pichler. Semantic width and the fixed-parameter tractability of constraint satisfaction problems. In Christian Bessiere, editor, IJCAI, pages 1726-1733, 2020. URL: https://doi.org/10.24963/ijcai.2020/239.
  11. Alin Deutsch, Nadime Francis, Alastair Green, Keith Hare, Bei Li, Leonid Libkin, Tobias Lindaaker, Victor Marsault, Wim Martens, Jan Michels, Filip Murlak, Stefan Plantikow, Petra Selmer, Oskar van Rest, Hannes Voigt, Domagoj Vrgoc, Mingxi Wu, and Fred Zemke. Graph pattern matching in GQL and SQL/PGQ. In Zachary Ives, Angela Bonifati, and Amr El Abbadi, editors, SIGMOD '22: International Conference on Management of Data, Philadelphia, PA, USA, June 12 - 17, 2022, pages 2246-2258. ACM, 2022. URL: https://doi.org/10.1145/3514221.3526057.
  12. Diego Figueira and Rémi Morvan. Approximation and Semantic Tree-width of Conjunctive Regular Path Queries. In 26th International Conference on Database Theory, Ioannina, Greece, mar 2023. Secondary link: https://www.morvan.xyz/papers/main-crpq-tw-icdt-v1.pdf. URL: https://doi.org/10.4230/LIPIcs.ICDT.2023.15.
  13. 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 Proc. of the 2018 International Conference on Management of Data, SIGMOD '18, pages 1433-1445, 2018. URL: https://doi.org/10.1145/3183713.3190657.
  14. Georg Gottlob, Nicola Leone, and Francesco Scarcello. Hypertree decompositions and tractable queries. Journal of Computer and System Sciences, 64(3):579-627, 2002. URL: https://doi.org/10.1006/jcss.2001.1809.
  15. Martin Grohe. The complexity of homomorphism and constraint satisfaction problems seen from the other side. J. ACM, 54(1):1:1-1:24, 2007. URL: https://doi.org/10.1145/1206035.1206036.
  16. Martin Grohe and Dániel Marx. Constraint solving via fractional edge covers. ACM Trans. Algorithms, 11(1), aug 2014. URL: https://doi.org/10.1145/2636918.
  17. Russell Impagliazzo, Ramamohan Paturi, and Francis Zane. Which problems have strongly exponential complexity? J. Comput. Syst. Sci., 63(4):512-530, 2001. URL: https://doi.org/10.1006/jcss.2001.1774.
  18. Dániel Marx. Tractable hypergraph properties for constraint satisfaction and conjunctive queries. In STOC, pages 735-744, 2010. URL: https://doi.org/10.1145/1806689.1806790.
  19. Alberto O. Mendelzon and Peter T. Wood. Finding regular simple paths in graph databases. SIAM Journal on Computing, 24(6):1235-1258, 1995. URL: https://doi.org/10.1137/S009753979122370X.
  20. Miguel Romero, Pablo Barceló, and Moshe Y. Vardi. The homomorphism problem for regular graph patterns. In 2017 32nd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS), pages 1-12, 2017. URL: https://doi.org/10.1109/LICS.2017.8005106.
  21. Sherif Sakr, Angela Bonifati, Hannes Voigt, Alexandru Iosup, Khaled Ammar, Renzo Angles, Walid Aref, Marcelo Arenas, Maciej Besta, Peter A. Boncz, Khuzaima Daudjee, Emanuele Della Valle, Stefania Dumbrava, Olaf Hartig, Bernhard Haslhofer, Tim Hegeman, Jan Hidders, Katja Hose, Adriana Iamnitchi, Vasiliki Kalavri, Hugo Kapp, Wim Martens, M. Tamer Özsu, Eric Peukert, Stefan Plantikow, Mohamed Ragab, Matei R. Ripeanu, Semih Salihoglu, Christian Schulz, Petra Selmer, Juan F. Sequeda, Joshua Shinavier, Gábor Szárnyas, Riccardo Tommasini, Antonino Tumeo, Alexandru Uta, Ana Lucia Varbanescu, Hsiang-Yun Wu, Nikolay Yakovets, Da Yan, and Eiko Yoneki. The future is big graphs: A community view on graph processing systems. Commun. ACM, 64(9):62-71, 2021. URL: https://doi.org/10.1145/3434642.
  22. Michael Sipser. Introduction to the Theory of Computation. Course Technology Inc., third edition, 2013. Google Scholar
  23. Oskar van Rest, Sungpack Hong, Jinha Kim, Xuming Meng, and Hassan Chafi. PGQL: A property graph query language. In Proceedings of the Fourth International Workshop on Graph Data Management Experiences and Systems, pages 1-6. ACM, 2016. URL: https://doi.org/10.1145/2960414.2960421.
  24. Mihalis Yannakakis. Algorithms for acyclic database schemes. In VLDB, pages 82-94, 1981. Google Scholar