Skip to main content

Compiling Graph Programs to C

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9761))

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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    In the double-pushout approach with injective matching.

  2. 2.

    Not to be confused with Haskell’s colon operator which adds an element to the beginning of a list.

References

  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)

    Article  Google Scholar 

  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. 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. 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. 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)

    Chapter  Google Scholar 

  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)

    Chapter  Google Scholar 

  7. Dörr, H. (ed.): Efficient Graph Rewriting and Its Implementation. LNCS, vol. 922. Springer, Heidelberg (1995)

    MATH  Google Scholar 

  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. 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)

    Article  Google Scholar 

  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)

    Article  Google Scholar 

  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. Plump, D.: The graph programming language GP. In: Bozapalidis, S., Rahonis, G. (eds.) CAI 2009. LNCS, vol. 5725, pp. 99–122. Springer, Heidelberg (2009)

    Chapter  Google Scholar 

  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. Poskitt, C.M., Plump, D.: Hoare-style verification of graph programs. Fundamenta Informaticae 118(1–2), 135–175 (2012)

    MathSciNet  MATH  Google Scholar 

  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)

    Chapter  Google Scholar 

  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)

    Chapter  Google Scholar 

  17. Sedgewick, R.: Algorithms in C: Part 5: Graph Algorithms. Addison-Wesley, New York (2002)

    Google Scholar 

  18. Skiena, S.S.: The Algorithm Design Manual, 2nd edn. Springer, London (2008)

    Book  MATH  Google Scholar 

  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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Detlef Plump .

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics