Document Open Access Logo

Linear-Time Graph Algorithms in GP 2

Authors Graham Campbell , Brian Courtehoute , Detlef Plump

Thumbnail PDF


  • Filesize: 0.53 MB
  • 23 pages

Document Identifiers

Author Details

Graham Campbell
  • Department of Computer Science, University of York, United Kingdom
Brian Courtehoute
  • Department of Computer Science, University of York, United Kingdom
Detlef Plump
  • Department of Computer Science, University of York, United Kingdom

Cite AsGet BibTex

Graham Campbell, Brian Courtehoute, and Detlef Plump. Linear-Time Graph Algorithms in GP 2. In 8th Conference on Algebra and Coalgebra in Computer Science (CALCO 2019). Leibniz International Proceedings in Informatics (LIPIcs), Volume 139, pp. 16:1-16:23, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2019)


GP 2 is an experimental programming language based on graph transformation rules which aims to facilitate program analysis and verification. However, implementing graph algorithms efficiently in a rule-based language is challenging because graph pattern matching is expensive. GP 2 mitigates this problem by providing rooted rules which, under mild conditions, can be matched in constant time. In this paper, we present linear-time GP 2 programs for three problems: tree recognition, binary directed acyclic graph (DAG) recognition, and topological sorting. In each case, we show the correctness of the program, prove its linear time complexity, and also give empirical evidence for the linear run time. For DAG recognition and topological sorting, the linear behaviour is achieved by implementing depth-first search strategies based on an encoding of stacks in graphs.

Subject Classification

ACM Subject Classification
  • Theory of computation → Design and analysis of algorithms
  • Graph transformation
  • rooted graph programs
  • GP 2
  • linear-time algorithms
  • depth-first search
  • topological sorting


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail