arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.09144cs.PLcs.PF
收藏

规则基图程序匹配命令式算法的时间复杂度

Rule-Based Graph Programs Matching the Time Complexity of Imperative Algorithms

University of Liverpool(利物浦大学);University of York(约克大学)

Ziad Ismaili Alaoui, Detlef Plump

AI总结:

通过增强GP 2编译器的图数据结构,实现了规则基图程序在连通性检测、无环性检测和单源最短路径问题上的时间复杂度与命令式实现相匹配。

摘要:

我们报告了基于规则的图编程的最新进展,这些进展使我们能够匹配一些基本命令式图算法的时间复杂度。通常,由于图匹配的成本,使用基于规则的图变换语言实现图算法的时间复杂度与使用传统语言实现的算法相当具有挑战性。先前的工作表明,使用有根规则,某些算法可以在图编程语言GP 2中实现,其运行时间与命令式实现的时间复杂度相匹配。然而,这要求输入图具有有界节点度,并且(对于某些算法)是连通的。在本文中,我们通过增强GP 2编译器生成的图数据结构并在程序中利用新结构来克服这些限制。我们提出了三个案例研究:第一个程序检查输入图是否连通,第二个程序检查输入图是否无环,第三个程序解决具有整数边权的图的单源最短路径问题。前两个程序在(可能不连通的)具有任意节点度的输入图上以线性时间运行。第三个程序在任意输入图上以$O(nm)$时间运行,与Bellman-Ford算法的命令式实现的时间复杂度相匹配。对于每个程序,我们正式证明了其正确性和时间复杂度,并提供了在各种图类上的运行时实验。

英文摘要:

We report on recent advances in rule-based graph programming, which allow us to match the time complexity of some fundamental imperative graph algorithms. In general, achieving the time complexity of graph algorithms implemented in conventional languages using a rule-based graph-transformation language is challenging due to the cost of graph matching. Previous work demonstrated that with rooted rules, certain algorithms can be implemented in the graph programming language GP 2 such that their runtime matches the time complexity of imperative implementations. However, this required input graphs to have a bounded node degree and (for some algorithms) to be connected. In this paper, we overcome these limitations by enhancing the graph data structure generated by the GP 2 compiler and exploiting the new structure in programs. We present three case studies: the first program checks whether input graphs are connected, the second program checks whether input graphs are acyclic, and the third program solves the single-source shortest-paths problem for graphs with integer edge-weights. The first two programs run in linear time on (possibly disconnected) input graphs with arbitrary node degrees. The third program runs in time $O(nm)$ on arbitrary input graphs, matching the time complexity of imperative implementations of the Bellman-Ford algorithm. For each program, we formally prove its correctness and time complexity, and provide runtime experiments on various graph classes.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑