Skip to main content

Simple Rectangle-Based Functional Programs for Computing Reflexive-Transitive Closures

  • Conference paper
Relational and Algebraic Methods in Computer Science (RAMICS 2012)

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

Abstract

We show how to systematically derive simple purely functional algorithms for computing the reflexive-transitive closure of directed graphs. Directed graphs can be represented as binary relations and we develop our algorithms based on a relation-algebraic description of reflexive-transitive closures. This description employs the relation-algebraic notion of rectangles and instantiating the resulting algorithm with different kinds of rectangles leads to different algorithms for computing reflexive-transitive closures. Using data refinement, we then develop simple Haskell programs for two specific choices of rectangles and show that one of them has cubic runtime like an imperative implementation of Warshall’s standard algorithm.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

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

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Berghammer, R., Ehler, H., Zierer, H.: Development of Graph Algorithms by Program Transformation. In: Göttler, H., Schneider, H.-J. (eds.) WG 1987. LNCS, vol. 314, pp. 206–218. Springer, Heidelberg (1988)

    Chapter  Google Scholar 

  2. Berghammer, R., Hoffmann, T.: Deriving relational programs for computing kernels by reconstructing a proof of Richardson’s theorem. Sci. of Comput. Progr. 38, 1–25 (2000)

    Article  MathSciNet  MATH  Google Scholar 

  3. Berghammer, R., Hoffmann, T.: Relational depth-first-search with applications. Inform. Sci. 139, 167–186 (2001)

    Article  MathSciNet  MATH  Google Scholar 

  4. Berghammer, R., Neumann, F.: RelView – An OBDD-Based Computer Algebra System for Relations. In: Ganzha, V.G., Mayr, E.W., Vorozhtsov, E.V. (eds.) CASC 2005. LNCS, vol. 3718, pp. 40–51. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  5. Berghammer, R., Fischer, S.: Implementing relational specifications in a constraint functional language. Electr. Notes on Theor. Comput. Sci. 177, 169–183 (2007)

    Article  MATH  Google Scholar 

  6. Berghammer, R., Struth, G.: On Automated Program Construction and Verification. In: Bolduc, C., Desharnais, J., Ktari, B. (eds.) MPC 2010. LNCS, vol. 6120, pp. 22–41. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  7. Berghammer, R.: A Functional, Successor List Based Version of Warshall’s Algorithm with Applications. In: de Swart, H. (ed.) RAMICS 2011. LNCS, vol. 6663, pp. 109–124. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

  8. Bird, R., Ravelo, J.: On computing representatives. Inf. Proc. Lett. 63, 1–7 (1997)

    Article  MathSciNet  MATH  Google Scholar 

  9. Bird, R.: Introduction to functional programming using Haskell, 2nd edn. Prentice Hall (1998)

    Google Scholar 

  10. Brunn, T., Möller, B., Russling, M.: Layered Graph Traversals and Hamiltonian Path Problems - An Algebraic Approach. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 96–121. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  11. Danilenko, N.: Using Relations to Develop a Haskell Program for Computing Maximum Bipartite Matchings. In: Kahl, W., Griffin, T.G. (eds.) RAMiCS 2012. LNCS, vol. 7560, pp. 130–145. Springer, Heidelberg (2012)

    Google Scholar 

  12. Erwig, M.: Graph Algorithms = Iteration + Data Structures? The Structure of Graph Algoritms and a Corresponding Style of Programming. In: Mayr, E.W. (ed.) WG 1992. LNCS, vol. 657, pp. 277–292. Springer, Heidelberg (1993)

    Chapter  Google Scholar 

  13. Erwig, M.: Functional programming with graphs. ACM SIGPLAN Notices 32, 52–65 (1997)

    Article  Google Scholar 

  14. Erwig, M.: Inductive graphs and functional graph algorithms. J. of Funct. Progr. 11, 467–492 (2001)

    Article  MathSciNet  MATH  Google Scholar 

  15. Floyd, R.W.: Algorithm 97 (Shortest path). Comm. of the ACM 5, 345 (1962)

    Article  Google Scholar 

  16. Fredmann, M.L.: New bounds on the complexity of the shortest path problem. SIAM J. on Comput. 5, 83–89 (1976)

    Article  MathSciNet  Google Scholar 

  17. Gibbons, J.: An Initial Algebra Approach to Directed Graphs. In: Möller, B. (ed.) MPC 1995. LNCS, vol. 947, pp. 282–303. Springer, Heidelberg (1995)

    Chapter  Google Scholar 

  18. Hanus, M.: The integration of functions into logic programming: From theory to practice. J. of Logic Progr. 19&20, 583–628 (1994)

    Article  MathSciNet  MATH  Google Scholar 

  19. Kahl, W.: Semigroupoid Interfaces for Relation-Algebraic Programming in Haskell. In: Schmidt, R.A. (ed.) RelMiCS/AKA 2006. LNCS, vol. 4136, pp. 235–250. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  20. King, D.J., Launchbury, J.: Structuring depth-first search algorithms in Haskell. In: Proc. ACM Symposium on Principles of Programming, pp. 344–356. ACM Press (1995)

    Google Scholar 

  21. Launchbury, J.: Graph Algorithms with a Functional Flavour. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 308–331. Springer, Heidelberg (1995)

    Chapter  Google Scholar 

  22. Ravelo, J.: Two graph algorithms derived. Acta Informat. 36, 489–510 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  23. Russling, M.: Deriving a class of layer-oriented graph algorithms. Sci. of Comput. Progr. 26, 117–132 (1996)

    Article  MathSciNet  MATH  Google Scholar 

  24. Schmidt, G., Ströhlein, T.: Relations and graphs. Discrete Mathematics for Computer Scientists. EATCS Monographs on Theoretical Computer Science. Springer (1993)

    Google Scholar 

  25. Schmidt, G.: A proposal for a multilevel relational reference language. J. of Relat. Meth. in Comput. Sci. 1, 314–338 (2004)

    Google Scholar 

  26. Schmidt, G.: Rectangles, Fringes, and Inverses. In: Berghammer, R., Möller, B., Struth, G. (eds.) RelMiCS/AKA 2008. LNCS, vol. 4988, pp. 352–366. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  27. Strassen, V.: Gaussian elimination is not optimal. Num. Math. 13, 354–356 (1969)

    Article  MathSciNet  MATH  Google Scholar 

  28. Tarski, A.: On the calculus of relations. J. of Symb. Logic 6, 73–89 (1941)

    Article  MathSciNet  MATH  Google Scholar 

  29. Thomson, S.: Haskell – The craft of functional programming. Addison-Wesley (1999)

    Google Scholar 

  30. Warshall, S.: A theorem on Boolean matrices. J. of the ACM 9, 11–12 (1962)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Berghammer, R., Fischer, S. (2012). Simple Rectangle-Based Functional Programs for Computing Reflexive-Transitive Closures. In: Kahl, W., Griffin, T.G. (eds) Relational and Algebraic Methods in Computer Science. RAMICS 2012. Lecture Notes in Computer Science, vol 7560. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-33314-9_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-33314-9_8

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-33313-2

  • Online ISBN: 978-3-642-33314-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics