Compiling Graph Programs to C

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


We show how to generate efficient C code for a high-level domain-specific language for graphs. The experimental language GP 2 is based on graph transformation rules and aims to facilitate formal reasoning on programs. Implementing graph programs is challenging because rule matching is expensive in general. GP 2 addresses this problem by providing rooted rules which under mild conditions can be matched in constant time. Using a search plan, our compiler generates C code for matching rooted graph transformation rules. We present run-time experiments with our implementation in a case study on checking graphs for two-colourability: on grid graphs of up to 100,000 nodes, the compiled GP 2 program is as fast as the tailor-made C program given by Sedgewick.


Root Node Outgoing Edge Graph Match Star Graph Adjacency List 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Agrawal, A., Karsai, G., Neema, S., Shi, F., Vizhanyo, A.: The design of a language for model transformations. Softw. Syst. Model. 5(3), 261–288 (2006)CrossRefGoogle Scholar
  2. 2.
    Bak, C.: GP 2: Efficient Implementation of a Graph Programming Language. Ph.D. thesis, Department of Computer Science, The University of York (2015)Google Scholar
  3. 3.
    Bak, C., Faulkner, G., Plump, D., Runciman, C.: A reference interpreter for the graph programming language GP 2. In: Proceedings of Graphs as Models (GaM 2015), vol. 181 of Electronic Proceedings in Theoretical Computer Science, pp. 48–64 (2015)Google Scholar
  4. 4.
    Bak, C., Plump, D.: Rooted graph programs. In: Proceedings of International Workshop on Graph-Based Tools (GraBaTs 2012), vol. 54 of Electronic Communications of the EASST (2012)Google Scholar
  5. 5.
    Veit Batz, G., Kroll, M., Geiß, R.: A first experimental evaluation of search plan driven graph pattern matching. In: Schürr, A., Nagl, M., Zündorf, A. (eds.) AGTIVE 2007. LNCS, vol. 5088, pp. 471–486. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  6. 6.
    Dodds, M., Plump, D.: Graph transformation in constant time. In: Corradini, A., Ehrig, H., Montanari, U., Ribeiro, L., Rozenberg, G. (eds.) ICGT 2006. LNCS, vol. 4178, pp. 367–382. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  7. 7.
    Dörr, H. (ed.): Efficient Graph Rewriting and Its Implementation. LNCS, vol. 922. Springer, Heidelberg (1995)zbMATHGoogle Scholar
  8. 8.
    Fernández, M., Kirchner, H., Mackie, I., Pinaud, B.: Visual modelling of complex systems: towards an abstract machine for PORGY. In: Beckmann, A., Csuhaj-Varjú, E., Meer, K. (eds.) CiE 2014. LNCS, vol. 8493, pp. 183–193. Springer, Heidelberg (2014)Google Scholar
  9. 9.
    Ghamarian, A.H., de Mol, M., Rensink, A., Zambon, E., Zimakova, M.: Modelling and analysis using GROOVE. Int. J. Softw. Tools Technol. Transf. 14(1), 15–40 (2012)CrossRefGoogle Scholar
  10. 10.
    Jakumeit, E., Buchwald, S., Kroll, M.: GrGen.NET - the expressive, convenient and fast graph rewrite system. Softw. Tools Technol. Transf. 12(3–4), 263–271 (2010)CrossRefGoogle Scholar
  11. 11.
    Manning, G., Plump, D.: The GP programming system. In: Proceedings of Graph Transformation and Visual Modelling Techniques (GT-VMT 2008), vol. 10 of Electronic Communications of the EASST (2008)Google Scholar
  12. 12.
    Plump, D.: The graph programming language GP. In: Bozapalidis, S., Rahonis, G. (eds.) CAI 2009. LNCS, vol. 5725, pp. 99–122. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  13. 13.
    Plump, D.: The design of GP 2. In: Proceedings of International Workshop on Reduction Strategies in Rewriting and Programming (WRS 2011), vol. 82 of Electronic Proceedings in Theoretical Computer Science, pp. 1–16 (2012)Google Scholar
  14. 14.
    Poskitt, C.M., Plump, D.: Hoare-style verification of graph programs. Fundamenta Informaticae 118(1–2), 135–175 (2012)MathSciNetzbMATHGoogle Scholar
  15. 15.
    Runge, O., Ermel, C., Taentzer, G.: AGG 2.0 – new features for specifying and analyzing algebraic graph transformations. In: Schürr, A., Varró, D., Varró, G. (eds.) AGTIVE 2011. LNCS, vol. 7233, pp. 81–88. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  16. 16.
    Schürr, A., Winter, A., Zündorf, A.: The PROGRES approach: language and environment. In: Ehrig, H., Kreowski, H.J., Rozenberg, G. (eds.) Handbook of Graph Grammars and Computing by Graph Transformation, pp. 487–550. World Scientific, Singapore (1999)CrossRefGoogle Scholar
  17. 17.
    Sedgewick, R.: Algorithms in C: Part 5: Graph Algorithms. Addison-Wesley, New York (2002)Google Scholar
  18. 18.
    Skiena, S.S.: The Algorithm Design Manual, 2nd edn. Springer, London (2008)CrossRefzbMATHGoogle Scholar
  19. 19.
    Vizhanyo, A., Agrawal, A., Shi, F.: Towards generation of efficient transformations. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, pp. 298–316. Springer, Heidelberg (2004)CrossRefGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2016

Authors and Affiliations

  1. 1.The University of YorkYorkUK

Personalised recommendations