Abstract
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.
C. Bak—This author’s work was supported by an EPSRC Doctoral Training Grant.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
In the double-pushout approach with injective matching.
- 2.
Not to be confused with Haskell’s colon operator which adds an element to the beginning of a list.
References
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)
Bak, C.: GP 2: Efficient Implementation of a Graph Programming Language. Ph.D. thesis, Department of Computer Science, The University of York (2015)
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)
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)
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)
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)
Dörr, H. (ed.): Efficient Graph Rewriting and Its Implementation. LNCS, vol. 922. Springer, Heidelberg (1995)
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)
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)
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)
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)
Plump, D.: The graph programming language GP. In: Bozapalidis, S., Rahonis, G. (eds.) CAI 2009. LNCS, vol. 5725, pp. 99–122. Springer, Heidelberg (2009)
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)
Poskitt, C.M., Plump, D.: Hoare-style verification of graph programs. Fundamenta Informaticae 118(1–2), 135–175 (2012)
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)
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)
Sedgewick, R.: Algorithms in C: Part 5: Graph Algorithms. Addison-Wesley, New York (2002)
Skiena, S.S.: The Algorithm Design Manual, 2nd edn. Springer, London (2008)
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)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing Switzerland
About this paper
Cite this paper
Bak, C., Plump, D. (2016). Compiling Graph Programs to C. In: Echahed, R., Minas, M. (eds) Graph Transformation. ICGT 2016. Lecture Notes in Computer Science(), vol 9761. Springer, Cham. https://doi.org/10.1007/978-3-319-40530-8_7
Download citation
DOI: https://doi.org/10.1007/978-3-319-40530-8_7
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-40529-2
Online ISBN: 978-3-319-40530-8
eBook Packages: Computer ScienceComputer Science (R0)