Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article
Free access

Functional programming with graphs

Published: 01 August 1997 Publication History
  • Get Citation Alerts
  • 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.

    References

    [1]
    A. Aasa, S. HolstrSm, and C. Nilsson. An Efficiency Comparison of Some Representations of Purely Functional Arrays. BIT, 28:490-503, 1988.
    [2]
    S. Adams. Efficient Sets - A Balancing Act. Journal o/Functional Programming, 3:553-561, 1993.
    [3]
    R. S. Bird. Functional Algorithm Design. In Mathematics of Program Construction, LNCS 947, pages 2-17, 1995.
    [4]
    F. W. Burton and H.-K. Yang. Manipulating Multilinked Data Structures in a Pure Functional Language. Sof'tware - Practice and E~'perience, 20(11):1167-1185, 1990.
    [5]
    P. F. Dietz. Fully Persistent Arrays. In Workshop on Algorithms and Data Structures, LNCS 382, pages 67- 74, 1989.
    [6]
    J. R. DriscoU, N. Sarnak, D. D. Sleator, and R. E. Tarjan. Making Data Structures Persistent. Journal o/ Computer and System Sciences, 38:86-124, 1989.
    [7]
    M. Erwig. Graph Algorithms = Iteration + Data Structures? The Structure of Graph Algorithms and a Corresponding Style of Programming. In 18th Int. Workshop on Graph Theoretic Concepts in Computer Science, LNCS 657, pages 277-292, 1992.
    [8]
    M. Erwig. Active Patterns. In 8th Int. Workshop on Implementation of Fur~etional Languages, pages 95-112, 1996. To appear in LNCS.
    [9]
    M. Erwig and B. Meyer. Heterogeneous Visual Languages- Integrating Visual and Textual Programming. In 11th IEEE Syrup. on Visual Languages, pages 318- 325, 1995.
    [10]
    L. Fegaras and T. Sheard. Revisiting Catamorphisms over Datatypes with Embedded Functions. In A CM Syrup. on Principles of Programming Languages, pages 284-294, 1996.
    [11]
    J. Gibbons. An Initial Algebra Approach to Directed Acyclic Graphs. In Mathematics of Program Construction, LNCS 947, pages 282-303, 1995.
    [12]
    Z. Hu, H. Iwasaki, and M. Takeic~. Deriving Structural Hylomorphisms from Recursive Definitions. In 1st Int. Conf. on Functional Programming, pages 73-82, 1996.
    [13]
    Y. Kashiwagi and D. Wise. Graph Algorithms in a Lazy Functional Programming Language. In 4th Int. Syrup. on Lucid and Intensional Programing, pages 35-46, 1991.
    [14]
    D. J. King and J. Launchbury. Structuring Depth-First Search Algorithms in Haskell. In A CM Syrup. on Principles of Programming Languages, pages 344-354, 1995.
    [15]
    J. Launchbury. Graph Algorithms with a Functional Flavour. In 1st Int. Spring School on Advanced Functional Programming, LNCS 925, pages 308-331, 1995.
    [16]
    J. Launchbury and T. Sheaxd. Warm Fusion: Deriving Build-Catas from Recursive Definitions. In Conf. on Functional Programming and Computer Architecture, pages 314-323, 1995.
    [17]
    G. Malcom. Homomorphisms and Promotability. In Mathematics of Program Construction, LNCS 375, pages 335-347, 1989.
    [18]
    E. Meijer, M. Fokkinga, and R. Paterson. Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire. In Conf. on P~nctional Programming and Computer Architecture, pages 124-144, 1991.
    [19]
    R. Milner, M. ToRe, and R. Harper. The Definition of Standard ML. MIT Press, Cambridge, MA, 1990.
    [20]
    C. Okasaki. Functional Data Structures. In Advanced Functional Programming, LNCS 1129, pages 131-158, 1996.
    [21]
    P. Palao Gonstanza, R. Pefia, and M. Ndfiez. A New Look at Pattern Matching in Abstract Data Types. In 1st Int. Conf. on Functional Programming, pages 110- 121, 1996.
    [22]
    T. Sheard and L. Fegaras. A Fold for all Seasons. In Conf. on Functional Programming and Computer At. chitecture, pages 233-242, 1993.
    [23]
    P. Wadler. Views: A Way for Pattern Matching to Cohabit with Data Abstraction. In A CM Syrup. on Principles of Programming Languages, pages 307-313, 1987.
    [24]
    P. Wadler. Deforestation: Transforming Programs to Eliminate Trees. Theoretical Computer Science, 73:231-284, 1990.

    Cited By

    View all

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 32, Issue 8
    Aug. 1997
    322 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/258949
    Issue’s Table of Contents
    • cover image ACM Conferences
      ICFP '97: Proceedings of the second ACM SIGPLAN international conference on Functional programming
      August 1997
      326 pages
      ISBN:0897919181
      DOI:10.1145/258948
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 01 August 1997
    Published in SIGPLAN Volume 32, Issue 8

    Check for updates

    Qualifiers

    • Article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)102
    • Downloads (Last 6 weeks)21
    Reflects downloads up to 11 Aug 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2022)Fregel: a functional domain-specific language for vertex-centric large-scale graph processingJournal of Functional Programming10.1017/S095679682100027732Online publication date: 20-Jan-2022
    • (2022)Folding over Neural NetworksMathematics of Program Construction10.1007/978-3-031-16912-0_5(129-150)Online publication date: 26-Sep-2022
    • (2020)Heterogeneous megamodel management using collection operatorsSoftware and Systems Modeling (SoSyM)10.1007/s10270-019-00738-919:1(231-260)Online publication date: 1-Jan-2020
    • (2018)Verifying the LTL to Büchi Automata Translation via Very Weak Alternating AutomataInteractive Theorem Proving10.1007/978-3-319-94821-8_18(306-323)Online publication date: 4-Jul-2018
    • (2018)Non-linear Pattern Matching with Backtracking for Non-free Data TypesProgramming Languages and Systems10.1007/978-3-030-02768-1_1(3-23)Online publication date: 22-Oct-2018
    • (2015)Enriching megamodel management with collection-based operatorsProceedings of the 18th International Conference on Model Driven Engineering Languages and Systems10.5555/3351736.3351766(236-245)Online publication date: 30-Sep-2015
    • (2015)Enriching megamodel management with collection-based operators2015 ACM/IEEE 18th International Conference on Model Driven Engineering Languages and Systems (MODELS)10.1109/MODELS.2015.7338254(236-245)Online publication date: Sep-2015
    • (2015)Combining relation algebra and data refinement to develop rectangle-based functional programs for reflexive–transitive closuresJournal of Logical and Algebraic Methods in Programming10.1016/j.jlamp.2014.08.00384:3(341-358)Online publication date: May-2015
    • (2014)Inductive representations of RDF graphsScience of Computer Programming10.1016/j.scico.2013.12.01195:P1(135-146)Online publication date: 1-Dec-2014
    • (2013)Inductive Triple GraphsRevised Selected Papers of the Third International Workshop on Graph Structures for Knowledge Representation and Reasoning - Volume 832310.1007/978-3-319-04534-4_7(92-110)Online publication date: 3-Aug-2013
    • Show More Cited By

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media