Functional programming with graphs
Author:
Open Access
- 1 August 1997
- conference paper
- Published by Association for Computing Machinery (ACM)
- Vol. 32 (8) , 52-65
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:
- Functional Pearls Efficient sets—a balancing actJournal of Functional Programming, 2008
- A new look at pattern matching in abstract data types1996
- Functional data structuresLecture Notes in Computer Science, 1996
- Warm fusion1995
- Structuring depth-first search algorithms in Haskell1995
- Functional Algorithm DesignLecture Notes in Computer Science, 1995
- A fold for all seasons1993
- Deforestation: transforming programs to eliminate treesTheoretical Computer Science, 1990
- Making data structures persistentJournal of Computer and System Sciences, 1989
- Homomorphisms and promotability1989