<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.3 20210610//EN" "JATS-journalpublishing1-3.dtd">
<article article-type="research-article" dtd-version="1.3" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="ru"><front><journal-meta><journal-id journal-id-type="publisher-id">ntv</journal-id><journal-title-group><journal-title xml:lang="ru">Научно-технический вестник информационных технологий, механики и оптики</journal-title><trans-title-group xml:lang="en"><trans-title>Scientific and Technical Journal of Information Technologies, Mechanics and Optics</trans-title></trans-title-group></journal-title-group><issn pub-type="ppub">2226-1494</issn><issn pub-type="epub">2500-0373</issn><publisher><publisher-name>Университет ИТМО</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.17586/2226-1494-2023-23-2-271-278</article-id><article-id custom-type="elpub" pub-id-type="custom">ntv-361</article-id><article-categories><subj-group subj-group-type="heading"><subject>Research Article</subject></subj-group><subj-group subj-group-type="section-heading" xml:lang="ru"><subject>КОМПЬЮТЕРНЫЕ СИСТЕМЫ И ИНФОРМАЦИОННЫЕ ТЕХНОЛОГИИ</subject></subj-group><subj-group subj-group-type="section-heading" xml:lang="en"><subject>COMPUTER SCIENCE</subject></subj-group></article-categories><title-group><article-title>Решение задачи достижимости в графе с заданными ограничениями в виде многокомпонентной контекстно-свободной грамматики с использованием умножения матриц</article-title><trans-title-group xml:lang="en"><trans-title>Multiple context-free path querying by matrix multiplication</trans-title></trans-title-group></title-group><contrib-group><contrib contrib-type="author" corresp="yes"><contrib-id contrib-id-type="orcid">https://orcid.org/0000-0003-2660-6193</contrib-id><name-alternatives><name name-style="eastern" xml:lang="ru"><surname>Эпельбаум</surname><given-names>И. В.</given-names></name><name name-style="western" xml:lang="en"><surname>Epelbaum</surname><given-names>I. V.</given-names></name></name-alternatives><bio xml:lang="ru"><p>Эпельбаум Илья Владимирович — студент, программист</p><p>Санкт-Петербург, 193313</p><p>sc 57218700891</p></bio><bio xml:lang="en"><p>lya V. Epelbaum — Student</p><p>Saint Petersburg, 193313</p><p>sc 57218700891</p></bio><email xlink:type="simple">ilya.epelbaum@gmail.com</email><xref ref-type="aff" rid="aff-1"/></contrib><contrib contrib-type="author" corresp="yes"><contrib-id contrib-id-type="orcid">https://orcid.org/0000-0003-0223-5172</contrib-id><name-alternatives><name name-style="eastern" xml:lang="ru"><surname>Азимов</surname><given-names>Р. Ш.</given-names></name><name name-style="western" xml:lang="en"><surname>Azimov</surname><given-names>R. Sh.</given-names></name></name-alternatives><bio xml:lang="ru"><p>Азимов Рустам Шухратуллович — старший преподаватель</p><p>Санкт-Петербург, 199034</p><p>sc 57203022098</p></bio><bio xml:lang="en"><p>Rustam Sh. Azimov — Senior Lecturer</p><p>Saint Petersburg, 199034</p><p>sc 57203022098</p></bio><email xlink:type="simple">rustam.azimov19021995@gmail.com</email><xref ref-type="aff" rid="aff-2"/></contrib><contrib contrib-type="author" corresp="yes"><contrib-id contrib-id-type="orcid">https://orcid.org/0000-0002-7966-0698</contrib-id><name-alternatives><name name-style="eastern" xml:lang="ru"><surname>Григорьев</surname><given-names>С. В.</given-names></name><name name-style="western" xml:lang="en"><surname>Grigorev</surname><given-names>S. V.</given-names></name></name-alternatives><bio xml:lang="ru"><p>Григорьев Семён Вячеславович — кандидат физико-математических наук, доцент</p><p>Санкт-Петербург, 199034</p><p>sc 56047575300</p></bio><bio xml:lang="en"><p>Semyon V. Grigorev — PhD (Physics &amp; Mathematics), Associate Professor</p><p>Saint Petersburg, 199034</p><p>sc 56047575300</p></bio><email xlink:type="simple">s.v.grigoriev@spbu.ru</email><xref ref-type="aff" rid="aff-2"/></contrib></contrib-group><aff-alternatives id="aff-1"><aff xml:lang="ru"><institution>ООО «КВЕРИФАЙ ЛАБС»</institution><country>Россия</country></aff><aff xml:lang="en"><institution>Querify Labs Ltd</institution><country>Russian Federation</country></aff></aff-alternatives><aff-alternatives id="aff-2"><aff xml:lang="ru"><institution>Санкт-Петербургский государственный университет</institution><country>Россия</country></aff><aff xml:lang="en"><institution>St. Petersburg State University (SPbSU)</institution><country>Russian Federation</country></aff></aff-alternatives><pub-date pub-type="collection"><year>2023</year></pub-date><pub-date pub-type="epub"><day>19</day><month>12</month><year>2024</year></pub-date><volume>23</volume><issue>2</issue><fpage>271</fpage><lpage>278</lpage><permissions><copyright-statement>Copyright &amp;#x00A9; Эпельбаум И.В., Азимов Р.Ш., Григорьев С.В., 2024</copyright-statement><copyright-year>2024</copyright-year><copyright-holder xml:lang="ru">Эпельбаум И.В., Азимов Р.Ш., Григорьев С.В.</copyright-holder><copyright-holder xml:lang="en">Epelbaum I.V., Azimov R.S., Grigorev S.V.</copyright-holder><license xml:lang="ru" license-type="creative-commons-attribution" xlink:href="https://creativecommons.org/licenses/by/4.0/" xlink:type="simple"><license-p>Данная работа распространяется под лицензией Creative Commons Attribution 4.0.</license-p></license><license xml:lang="en" license-type="creative-commons-attribution" xlink:href="https://creativecommons.org/licenses/by/4.0/" xlink:type="simple"><license-p>This work is licensed under a Creative Commons Attribution 4.0 License.</license-p></license></permissions><self-uri xlink:href="https://ntv.elpub.ru/jour/article/view/361">https://ntv.elpub.ru/jour/article/view/361</self-uri><abstract><p>Предмет исследования. Многие задачи анализа графов могут быть сформулированы как задачи поиска путей с ограничениями в виде формальных языков. В последнее время задача достижимости в графе с заданными ограничениями в виде контекстно-свободных языков стала очень популярной и используется во многих областях, например, для запросов к графовым базам данных, для анализа RDF (Resource Description Framework) данных. Однако некоторые сложные ограничения на пути в графе не могут быть описаны с помощью контекстно-свободных языков, поэтому были предложены различные расширения. Многокомпонентные контекстно-свободные языки — одно из таких расширений. В данной работе представлены результаты разработки первого алгоритма поиска путей в графе с заданными ограничениями в виде многокомпонентных контекстно-свободных языков. Метод. Сущность предложенного алгоритма состоит в использовании набора булевых матриц и операций над ними для поиска путей в графе, удовлетворяющих заданным ограничениям. Основной операцией является умножение булевых матриц. В качестве результата алгоритм возвращает набор матриц, содержащий всю информацию, необходимую для решения задачи достижимости в графе с заданными ограничениями в виде многокомпонентного контекстно-свободного языка. Основные результаты. Представленный алгоритм реализован на языке Python с использованием стандарта GraphBLAS. Выполнен анализ реальных RDF данных и синтетических графов для некоторых классических многокомпонентных контекстно-свободных языков. Исследование показало, что при использовании разреженного формата для хранения матриц и параллельных вычислений для графов с десятками тысяч ребер время анализа может составлять 10–20 минут. Результат проведенного анализа представляет десятки миллионов пар достижимых вершин. Практическая значимость. Разработанный алгоритм может быть применен в задачах статического анализа программ, в биоинформатике, в сетевом анализе, а также в графовых базах данных, когда ограничения на пути в графе не могут быть выражены с помощью контекстно свободных грамматик. Алгоритм основан на операциях линейной алгебры, что позволяет использовать высокопроизводительные библиотеки и задействовать современные параллельные вычислительные системы.</p></abstract><trans-abstract xml:lang="en"><p>Many graph analysis problems can be formulated as formal language-constrained path querying problems where the formal languages are used as constraints for navigational path queries. Recently, the context-free language (CFL) reachability formulation has become very popular and can be used in many areas, for example, querying graph databases, Resource Description Framework (RDF) analysis. However, the generative capacity of context-free grammars (CFGs) is too weak to generate some complex queries, for example, from natural languages, and the various extensions of CFGs have been proposed. Multiple context-free grammar (MCFG) is one of such extensions of CFGs. Despite the fact that, to the best of our knowledge, there is no algorithm for MCFL-reachability, this problem is known to be decidable. This paper is devoted to developing the first such algorithm for the MCFL-reachability problem. The essence of the proposed algorithm is to use a set of Boolean matrices and operations on them to find paths in a graph that satisfy the given constraints. The main operation here is Boolean matrix multiplication. As a result, the algorithm returns a set of matrices containing all information needed to solve the MCFL-reachability problem. The presented algorithm is implemented in Python using GraphBLAS API. An analysis of real RDF data and synthetic graphs for some MCFLs is performed. The study showed that using a sparse format for matrix storage and parallel computing for graphs with tens of thousands of edges the analysis time can be 10–20 minutes. The result of the analysis provides tens of millions of reachable vertex pairs. The proposed algorithm can be applied in problems of static code analysis, bioinformatics, network analysis, as well as in graph databases when a path query cannot be expressed using context-free grammars. The provided algorithm is linear algebra-based, hence, it allows one to use high-performance libraries and utilize modern parallel hardware.</p></trans-abstract><kwd-group xml:lang="ru"><kwd>анализ графов</kwd><kwd>многокомпонентные КС-грамматики</kwd><kwd>графовые базы данных</kwd><kwd>RDF</kwd><kwd>умножение булевых матриц</kwd><kwd>стандарт GraphBLAS</kwd></kwd-group><kwd-group xml:lang="en"><kwd>path querying</kwd><kwd>MCFG</kwd><kwd>graph databases</kwd><kwd>RDF</kwd><kwd>Boolean matrix multiplication</kwd><kwd>GraphBLAS API</kwd></kwd-group><funding-group><funding-statement xml:lang="ru">Исследование выполнено при финансовой поддержке Российского научного фонда в рамках научного проекта № 18-11-00100.</funding-statement><funding-statement xml:lang="en">The research was supported by the Russian Science Foundation, Grant 18-11-00100</funding-statement></funding-group></article-meta></front><back><ref-list><title>References</title><ref id="cit1"><label>1</label><citation-alternatives><mixed-citation xml:lang="ru">Barrett C., Jacob R., Marathe M. Formal-language-constrained path problems // SIAM Journal on Computing. 2000. V. 30. N 3. P. 809– 837. https://doi.org/10.1137/S0097539798337716</mixed-citation><mixed-citation xml:lang="en">Barrett C., Jacob R., Marathe M. Formal-language-constrained path problems. SIAM Journal on Computing, 2000, vol. 30, no. 3, pp. 809– 837. https://doi.org/10.1137/S0097539798337716</mixed-citation></citation-alternatives></ref><ref id="cit2"><label>2</label><citation-alternatives><mixed-citation xml:lang="ru">Terekhov A., Khoroshev A., Azimov R., Grigorev S. Context-free path querying with single-path semantics by matrix multiplication // Proc. of the 3 rd Joint International Workshop on Graph Data Management Experiences &amp; Systems (GRADES) and Network Data Analytics (NDA ). 2020. P. 1 – 12. https://doi.org/10.1145/3398682.3399163</mixed-citation><mixed-citation xml:lang="en">Terekhov A., Khoroshev A., Azimov R., Grigorev S. Context-free path querying with single-path semantics by matrix multiplication. Proc. of the 3 rd Joint International Workshop on Graph Data Management Experiences &amp; Systems (GRADES) and Network Data Analytics ( NDA ) , 2020, pp. 1 – 12 . https://doi.org/10.1145/3398682.3399163</mixed-citation></citation-alternatives></ref><ref id="cit3"><label>3</label><citation-alternatives><mixed-citation xml:lang="ru">Zhang X., Feng Z., Wang X., Rao G., Wu W. Context-free path queries on RDF graphs // Lecture Notes in Computer Science. 2016. V. 9981. P. 632–648. https://doi.org/10.1007/978-3-319-46523-4_38</mixed-citation><mixed-citation xml:lang="en">Zhang X., Feng Z., Wang X., Rao G., Wu W. Context-free path queries on RDF graphs. Lecture Notes in Computer Science, 2016, vol. 9981, pp. 632–648. https://doi.org/10.1007/978-3-319-46523-4_38</mixed-citation></citation-alternatives></ref><ref id="cit4"><label>4</label><citation-alternatives><mixed-citation xml:lang="ru">Zheng X., Rugina R. Demand-driven alias analysis for C // Proc. of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 2008. P. 197–208. https://doi.org/10.1145/1328438.1328464</mixed-citation><mixed-citation xml:lang="en">Zheng X., Rugina R. Demand-driven alias analysis for C. Proc. of the 35 th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2008, pp. 197–208. https://doi.org/10.1145/1328438.1328464</mixed-citation></citation-alternatives></ref><ref id="cit5"><label>5</label><citation-alternatives><mixed-citation xml:lang="ru">Sevon P., Eronen L. Subgraph queries by context-free grammars // Journal of Integrative Bioinformatics. 2008. V. 5. N 2. P. 157–172. https://doi.org/10.1515/jib-2008-100</mixed-citation><mixed-citation xml:lang="en">Sevon P., Eronen L. Subgraph queries by context-free grammars. Journal of Integrative Bioinformatics, 2008, vol. 5, no. 2, pp. 157– 172. https://doi.org/10.1515/jib-2008-100</mixed-citation></citation-alternatives></ref><ref id="cit6"><label>6</label><citation-alternatives><mixed-citation xml:lang="ru">Zhang Q., Lyu M.R., Yuan H., Su Z. Fast algorithms for dyck-cflreachability with applications to alias analysis // Proc. of the 34 th ACM SIGPLAN Conference on Programming Language Design and Implementation. 2013. P. 435 – 446 .https://doi.org/10.1145/2491956.2462159</mixed-citation><mixed-citation xml:lang="en">Zhang Q., Lyu M.R., Yuan H., Su Z. Fast algorithms for dyck-cflreachability with applications to alias analysis. Proc. of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation, 2013, pp. 435 – 446. https://doi.org/10.1145/2491956.2462159</mixed-citation></citation-alternatives></ref><ref id="cit7"><label>7</label><citation-alternatives><mixed-citation xml:lang="ru">Reps T. Undecidability of context-sensitive data-dependence analysis // ACM Transactions on Programming Languages and Systems. 2000. V. 22. N 1. P. 162–186. https://doi.org/10.1145/345099.345137</mixed-citation><mixed-citation xml:lang="en">Reps T. Undecidability of context-sensitive data-dependence analysis. ACM Transactions on Programming Languages and Systems, 2000, vol. 22, no. 1, pp. 162–186. https://doi.org/10.1145/345099.345137</mixed-citation></citation-alternatives></ref><ref id="cit8"><label>8</label><citation-alternatives><mixed-citation xml:lang="ru">Hopcroft J.E., Motwani R., Ullman J.D. Introduction to automata theory, languages, and computation // ACM Sigact News. 2001. V. 32. N 1. P. 60–65. https://doi.org/10.1145/568438.568455</mixed-citation><mixed-citation xml:lang="en">Hopcroft J.E., Motwani R., Ullman J.D. Introduction to automata theory, languages, and computation. ACM Sigact News, 2001, vol. 32, no. 1, pp. 60–65. https://doi.org/10.1145/568438.568455</mixed-citation></citation-alternatives></ref><ref id="cit9"><label>9</label><citation-alternatives><mixed-citation xml:lang="ru">Zhang Q., Su Z. Context-sensitive data-dependence analysis via linear conjunctive language reachability // Proc. of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages. 2017. P. 344– 358. https://doi.org/10.1145/3009837.3009848</mixed-citation><mixed-citation xml:lang="en">Zhang Q., Su Z. Context-sensitive data-dependence analysis via linear conjunctive language reachability. Proc. of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, 2017, pp. 344– 358. https://doi.org/10.1145/3009837.3009848</mixed-citation></citation-alternatives></ref><ref id="cit10"><label>10</label><citation-alternatives><mixed-citation xml:lang="ru">Kepner J., Aaltonen P., Bader D., Buluç A., Franchetti F., Gilbert J., Hutchison D., Kumar M., Lumsdaine A., Meyerhenke H., McMillan S., Yang C., Owens J.D., Zalewski M., Mattson T., Moreira J. Mathematical foundations of the graphblas // Proc. of the 2016 IEEE High Performance Extreme Computing Conference (HPEC). 2016. P. 1–9. https://doi.org/10.1109/hpec.2016.7761646</mixed-citation><mixed-citation xml:lang="en">Kepner J., Aaltonen P., Bader D., Buluç A., Franchetti F., Gilbert J., Hutchison D., Kumar M., Lumsdaine A., Meyerhenke H., McMillan S., Yang C., Owens J.D., Zalewski M., Mattson T., Moreira J. Mathematical foundations of the graphblas. Proc. of the 2016 IEEE High Performance Extreme Computing Conference (HPEC), 2016, pp. 1–9. https://doi.org/10.1109/hpec.2016.7761646</mixed-citation></citation-alternatives></ref><ref id="cit11"><label>11</label><citation-alternatives><mixed-citation xml:lang="ru">Azimov R., Epelbaum I., Grigorev S. Context-free path querying with all-path semantics by matrix multiplication // Proc. of the 4 th ACM SIGMOD Joint International Workshop on Graph Data Management Experiences &amp; Systems (GRADES) and Network Data Analytics (NDA). 2021. P. 1–7. https://doi.org/10.1145/3461837.3464513</mixed-citation><mixed-citation xml:lang="en">Azimov R., Epelbaum I., Grigorev S. Context-free path querying with all-path semantics by matrix multiplication. Proc. of the 4 th ACM SIGMOD Joint International Workshop on Graph Data Management Experiences &amp; Systems (GRADES) and Network Data Analytics (NDA), 2021, pp. 1–7. https://doi.org/10.1145/3461837.3464513</mixed-citation></citation-alternatives></ref><ref id="cit12"><label>12</label><citation-alternatives><mixed-citation xml:lang="ru">Azimov R., Grigorev S. Context-free path querying by matrix multiplication // Proc. of the 1 st ACM SIGMOD Joint International Workshop on Graph Data Management Experiences &amp; Systems (GRADES) and Network Data Analytics (NDA). 2018. P. 1–10. https://doi.org/10.1145/3210259.3210264</mixed-citation><mixed-citation xml:lang="en">Azimov R., Grigorev S. Context-free path querying by matrix multiplication. Proc. of the 1 st ACM SIGMOD Joint International Workshop on Graph Data Management Experiences &amp; Systems (GRADES) and Network Data Analytics (NDA), 2018, pp. 1–10. https://doi.org/10.1145/3210259.3210264</mixed-citation></citation-alternatives></ref><ref id="cit13"><label>13</label><citation-alternatives><mixed-citation xml:lang="ru">Nakanish, R., Takada K., Seki H. An efficient recognition algorithm for multiple context-free languages // Proc. of the 5th Meeting on the Mathematics of Language (MOL5). 1997. P. 119–123.</mixed-citation><mixed-citation xml:lang="en">Nakanish R., Takada K., Seki H. An efficient recognition algorithm for multiple context-free languages. Proc. of the 5th Meeting on the Mathematics of Language (MOL5), 1997, pp. 119–123.</mixed-citation></citation-alternatives></ref><ref id="cit14"><label>14</label><citation-alternatives><mixed-citation xml:lang="ru">Cohen S.B., Gildea D. Parsing linear context-free rewriting systems with fast matrix multiplication // Computational Linguistics. 2016. V. 42. N 3. P. 421–455. https://doi.org/10.1162/coli_a_00254</mixed-citation><mixed-citation xml:lang="en">Cohen S.B., Gildea D. Parsing linear context-free rewriting systems with fast matrix multiplication. Computational Linguistics, 2016, vol. 42, no. 3, pp. 421–455. https://doi.org/10.1162/coli_a_00254</mixed-citation></citation-alternatives></ref><ref id="cit15"><label>15</label><citation-alternatives><mixed-citation xml:lang="ru">Seki H., Matsumura T., Fujii M., Kasami T. On multiple context-free grammars // Theoretical Computer Science. 1991. V. 88. N 2. P. 191– 229. https://doi.org/10.1016/0304-3975(91)90374-B</mixed-citation><mixed-citation xml:lang="en">Seki H., Matsumura T., Fujii M., Kasami T. On multiple context-free grammars. Theoretical Computer Science, 1991, vol. 88, no. 2, pp. 191–229. https://doi.org/10.1016/0304-3975(91)90374-B</mixed-citation></citation-alternatives></ref><ref id="cit16"><label>16</label><citation-alternatives><mixed-citation xml:lang="ru">Hagberg A., Schult D., Swart P. Exploring network structure, dynamics, and function using network // Proc. of the 7 th Python in Science Conference (SciPy 2008). 2008. P. 11–15</mixed-citation><mixed-citation xml:lang="en">Hagberg A., Schult D., Swart P. Exploring network structure, dynamics, and function using network, Proc. of the 7 th Python in Science Conference (SciPy 2008), 2008, pp. 11–15.</mixed-citation></citation-alternatives></ref></ref-list><fn-group><fn fn-type="conflict"><p>The authors declare that there are no conflicts of interest present.</p></fn></fn-group></back></article>
