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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
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)
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)
Berghammer, R., Hoffmann, T.: Relational depth-first-search with applications. Inform. Sci. 139, 167–186 (2001)
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)
Berghammer, R., Fischer, S.: Implementing relational specifications in a constraint functional language. Electr. Notes on Theor. Comput. Sci. 177, 169–183 (2007)
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)
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)
Bird, R., Ravelo, J.: On computing representatives. Inf. Proc. Lett. 63, 1–7 (1997)
Bird, R.: Introduction to functional programming using Haskell, 2nd edn. Prentice Hall (1998)
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)
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)
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)
Erwig, M.: Functional programming with graphs. ACM SIGPLAN Notices 32, 52–65 (1997)
Erwig, M.: Inductive graphs and functional graph algorithms. J. of Funct. Progr. 11, 467–492 (2001)
Floyd, R.W.: Algorithm 97 (Shortest path). Comm. of the ACM 5, 345 (1962)
Fredmann, M.L.: New bounds on the complexity of the shortest path problem. SIAM J. on Comput. 5, 83–89 (1976)
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)
Hanus, M.: The integration of functions into logic programming: From theory to practice. J. of Logic Progr. 19&20, 583–628 (1994)
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)
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)
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)
Ravelo, J.: Two graph algorithms derived. Acta Informat. 36, 489–510 (1999)
Russling, M.: Deriving a class of layer-oriented graph algorithms. Sci. of Comput. Progr. 26, 117–132 (1996)
Schmidt, G., Ströhlein, T.: Relations and graphs. Discrete Mathematics for Computer Scientists. EATCS Monographs on Theoretical Computer Science. Springer (1993)
Schmidt, G.: A proposal for a multilevel relational reference language. J. of Relat. Meth. in Comput. Sci. 1, 314–338 (2004)
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)
Strassen, V.: Gaussian elimination is not optimal. Num. Math. 13, 354–356 (1969)
Tarski, A.: On the calculus of relations. J. of Symb. Logic 6, 73–89 (1941)
Thomson, S.: Haskell – The craft of functional programming. Addison-Wesley (1999)
Warshall, S.: A theorem on Boolean matrices. J. of the ACM 9, 11–12 (1962)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)