Structuring depth-first search algorithms in Haskell

  • Authors:
  • David J. King;John Launchbury

  • Affiliations:
  • Department of Computing Science, University of Glasgow, Glasgow G12 8QQ, UK;Department of Computer Science and Engineering, Oregon Graduate Institute of Science & Technology, Beaverton, Oregon

  • Venue:
  • POPL '95 Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
  • Year:
  • 1995

Quantified Score

Hi-index 0.00

Visualization

Abstract

Depth-first search is the key to a wide variety of graph algorithms. In this paper we express depth-first search in a lazy functional language, obtaining a linear-time implementation. Unlike traditional imperative presentations, we use the structuring methods of functional languages to construct algorithms from individual reusable components. This style of algorithm construction turns out to be quite amenable to formal proof, which we exemplify through a calculational-style proof of a far from obvious strongly-connected components algorithm.