Functional programming with graphs
- 1 August 1997
- proceedings article
- Published by Association for Computing Machinery (ACM)
- Vol. 32 (8) , 52-65
- https://doi.org/10.1145/258948.258955
Abstract
Graph algorithms expressed in functional languages often suffer from their inherited imperative, state-based style. In particular, this impedes formal program manipulation. We show how to model persistent graphs in functional languages by graph constructors. This provides a decompositional view of graphs which is very close to that of data types and leads to a "more fictional" formulation of graph algorithms. Graph constructors enable the definition of general fold operations for graphs. We present a promotion theorem for one of these folds that allows program fusion and the elimination of intermediate results. Fusion is not restricted to the elimination of tree-like structures, and we prove another theorem that facilitates the elimination of intermediate graphs. We describe an ML-implementation of persistent graphs which efficiently supports the presented fold operators. For example, depth-first-search expressed by a fold over a functional graph has the same complexity as the corresponding imperative algorithm.Keywords
This publication has 13 references indexed in Scilit:
- A new look at pattern matching in abstract data typesPublished by Association for Computing Machinery (ACM) ,1996
- Functional data structuresPublished by Springer Nature ,1996
- Warm fusionPublished by Association for Computing Machinery (ACM) ,1995
- Structuring depth-first search algorithms in HaskellPublished by Association for Computing Machinery (ACM) ,1995
- Functional Algorithm DesignPublished by Springer Nature ,1995
- Functional Pearls Efficient sets—a balancing actJournal of Functional Programming, 1993
- A fold for all seasonsPublished by Association for Computing Machinery (ACM) ,1993
- Deforestation: transforming programs to eliminate treesTheoretical Computer Science, 1990
- Making data structures persistentJournal of Computer and System Sciences, 1989
- Homomorphisms and promotabilityPublished by Springer Nature ,1989