Context-Free Path Querying by Kronecker Product

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 12245)


Context-free path queries (CFPQ) extend the regular path queries (RPQ) by allowing context-free grammars to be used as constraints for paths. Algorithms for CFPQ are actively developed, but J. Kuijpers et al. have recently concluded, that existing algorithms are not performant enough to be used in real-world applications. Thus the development of new algorithms for CFPQ is justified. In this paper, we provide a new CFPQ algorithm which is based on such linear algebra operations as Kronecker product and transitive closure and handles grammars presented as recursive state machines. Thus, the proposed algorithm can be implemented by using high-performance libraries and modern parallel hardware. Moreover, it avoids grammar growth which provides the possibility for queries optimization.


Context-free path querying Graph database Context-free grammars CFPQ Kronecker product Recursive state machines 


  1. 1.
    Alur, R., Etessami, K., Yannakakis, M.: Analysis of recursive state machines. In: Berry, G., Comon, H., Finkel, A. (eds.) CAV 2001. LNCS, vol. 2102, pp. 207–220. Springer, Heidelberg (2001). Scholar
  2. 2.
    Azimov, R., Grigorev, S.: Context-free path querying by matrix multiplication. In: Proceedings of the 1st ACM SIGMOD Joint International Workshop on Graph Data Management Experiences & Systems (GRADES) and Network Data Analytics (NDA), GRADES-NDA 2018, pp. 5:1–5:10. ACM, New York (2018).
  3. 3.
    Barrett, C., Jacob, R., Marathe, M.: Formal-language-constrained path problems. SIAM J. Comput. 30(3), 809–837 (2000). Scholar
  4. 4.
    Davis, T.A.: Algorithm 9xx: SuiteSparse: GraphBLAS: graph algorithms in the language of sparse linear algebra (2018)Google Scholar
  5. 5.
    Hellings, J.: Querying for paths in graphs using context-free path queries. arXiv preprint arXiv:1502.02242 (2015)
  6. 6.
    Hemerik, K.: Towards a taxonomy for ECFG and RRPG parsing. In: Dediu, A.H., Ionescu, A.M., Martín-Vide, C. (eds.) LATA 2009. LNCS, vol. 5457, pp. 410–421. Springer, Heidelberg (2009). Scholar
  7. 7.
    Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation, 3rd edn. Addison-Wesley Longman Publishing Co., Inc., Boston (2006)zbMATHGoogle Scholar
  8. 8.
    Kepner, J., et al.: Mathematical foundations of the GraphBLAS. In: 2016 IEEE High Performance Extreme Computing Conference (HPEC), pp. 1–9, September 2016.
  9. 9.
    Kuijpers, J., Fletcher, G., Yakovets, N., Lindaaker, T.: An experimental study of context-free path query evaluation methods. In: Proceedings of the 31st International Conference on Scientific and Statistical Database Management, SSDBM 2019, pp. 121–132. Association for Computing Machinery, New York (2019).
  10. 10.
    Medeiros, C.M., Musicante, M.A., Costa, U.S.: Efficient evaluation of context-free path queries for graph databases. In: Proceedings of the 33rd Annual ACM Symposium on Applied Computing, SAC 2018, pp. 1230–1237. ACM, New York (2018).
  11. 11.
    Mishin, N., et al.: Evaluation of the context-free path querying algorithm based on matrix multiplication. In: Proceedings of the 2nd Joint International Workshop on Graph Data Management Experiences & Systems (GRADES) and Network Data Analytics (NDA), GRADES-NDA 2019. Association for Computing Machinery, New York (2019).
  12. 12.
    Sevon, P., Eronen, L.: Subgraph queries by context-free grammars. J. Integr. Bioinform. 5(2), 100 (2008)CrossRefGoogle Scholar
  13. 13.
    Yannakakis, M.: Graph-theoretic methods in database theory. In: Proceedings of the Ninth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, PODS 1990, pp. 230–242. ACM, New York (1990).
  14. 14.
    Zhang, X., Feng, Z., Wang, X., Rao, G., Wu, W.: Context-free path queries on RDF graphs. In: Groth, P., et al. (eds.) ISWC 2016. LNCS, vol. 9981, pp. 632–648. Springer, Cham (2016). Scholar

Copyright information

© Springer Nature Switzerland AG 2020

Authors and Affiliations

  1. 1.St. Petersburg State UniversitySt. PetersburgRussia
  2. 2.JetBrains ResearchSt. PetersburgRussia

Personalised recommendations