Linear-Time Graph Programs without Preconditions

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Alaoui, Ziad Ismaili, Plump, Detlef
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915213885833216
author Alaoui, Ziad Ismaili
Plump, Detlef
author_facet Alaoui, Ziad Ismaili
Plump, Detlef
contents We report on a recent breakthrough in rule-based graph programming, which allows us to reach the time complexity of imperative linear-time algorithms. In general, achieving the complexity of graph algorithms in conventional languages using graph transformation rules is challenging due to the cost of graph matching. Previous work demonstrated that with rooted rules, certain algorithms can be executed in linear time using the graph programming language GP 2. However, for non-destructive algorithms that retain the structure of input graphs, achieving linear runtime required input graphs to be connected and of bounded node degree. In this paper, we overcome these preconditions by enhancing the graph data structure generated by the GP 2 compiler and exploiting the new structure in programs. We present three case studies, a cycle detection program, a program for numbering the connected components of a graph, and a breadth-first search program. Each of these programs runs in linear time on both connected and disconnected input graphs with arbitrary node degrees. We give empirical evidence for the linear time complexity by using timings for various classes of input graphs.
format Preprint
id arxiv_https___arxiv_org_abs_2503_20465
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Linear-Time Graph Programs without Preconditions
Alaoui, Ziad Ismaili
Plump, Detlef
Programming Languages
Logic in Computer Science
Performance
D.3.4; F.2
We report on a recent breakthrough in rule-based graph programming, which allows us to reach the time complexity of imperative linear-time algorithms. In general, achieving the complexity of graph algorithms in conventional languages using graph transformation rules is challenging due to the cost of graph matching. Previous work demonstrated that with rooted rules, certain algorithms can be executed in linear time using the graph programming language GP 2. However, for non-destructive algorithms that retain the structure of input graphs, achieving linear runtime required input graphs to be connected and of bounded node degree. In this paper, we overcome these preconditions by enhancing the graph data structure generated by the GP 2 compiler and exploiting the new structure in programs. We present three case studies, a cycle detection program, a program for numbering the connected components of a graph, and a breadth-first search program. Each of these programs runs in linear time on both connected and disconnected input graphs with arbitrary node degrees. We give empirical evidence for the linear time complexity by using timings for various classes of input graphs.
title Linear-Time Graph Programs without Preconditions
topic Programming Languages
Logic in Computer Science
Performance
D.3.4; F.2
url https://arxiv.org/abs/2503.20465