Hostname: page-component-76fb5796d-x4r87 Total loading time: 0 Render date: 2024-04-25T12:50:59.030Z Has data issue: false hasContentIssue false

Functional Pearls

Deriving tidy drawings of trees

Published online by Cambridge University Press:  07 November 2008

Jeremy Gibbons
Affiliation:
Department of Computer Science, University of Auckland, Private Bag 92019, Auckland, New Zealand. Email jeremy@cs. auckland. ac.nz
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

The tree-drawing problem is to produce a ‘tidy’ mapping from elements of a tree to points in the plane. In this paper, we derive an efficient algorithm for producing tidy drawings of trees. The specification, the starting point for the derivations, consists of a collection of intuitively appealing criteria satisfied by tidy drawings. The derivation shows constructively that these criteria completely determine the drawing. Indeed, the criteria completely determine a simple but inefficient algorithm for drawing a tree, which can be transformed into an efficient algorithm using just standard techniques and a small number of inventive steps.

The algorithm consists of an upwards accumulation followed by a downwards accumulation on the tree, and is further evidence of the utility of these two higher-order tree operations.

Type
Articles
Copyright
Copyright © Cambridge University Press 1996

References

Backhouse, Roland (1989). An exploration of the Bird-Meertens formalism. In International Summer School on Constructive Algorithmics, Hollum, Ameland. STOP project. Also available as Technical Report CS 8810, Department of Computer Science, Groningen University, 1988.Google Scholar
Bird, Richard S. (1987). An introduction to the theory of lists. In Broy, M., editor, Logic of Programming and Calculi of Discrete Design, pages 342. Springer-Verlag. Also available as Technical Monograph PRG-56, from the Programming Research Group, Oxford University.Google Scholar
Bird, Richard S. (1988). Lectures on constructive functional programming. In Broy, Manfred, editor, Constructive Methods in Computer Science. Springer-Verlag. Also available as Technical Monograph PRG-69, from the Programming Research Group, Oxford University.Google Scholar
Bloesch, Anthony (1993). Aesthetic layout of generalized trees. Software—Practice and Experience, 23(8):817827.CrossRefGoogle Scholar
Brüggemann-Klein, Anne and Wood, Derick (1990). Drawing trees nicely with TEX. In Clark, Malcolm, editor, TEX: Applications, Uses, Methods, pages 185206. Ellis Horwood.Google Scholar
Deransart, Pierre, Jourdan, Martin, and Lorho, Bernard (1988). LNCS 323: Attribute Grammars—Definitions, Systems and Bibliography. Springer-Verlag.Google Scholar
Gibbons, Jeremy, Cai, Wentong, and Skillicorn, David (1994). Efficient parallel algorithms for tree accumulations. Science of Computer Programming, 23:118.Google Scholar
Gibbons, Jeremy (1991). Algebras for Tree Algorithms. D. Phil. thesis, Programming Research Group, Oxford University. Available as Technical Monograph PRG-94.Google Scholar
Gibbons, Jeremy (1993a). Computing downwards accumulations on trees quickly. In Gupta, Gopal, Mohay, George, and Topor, Rodney, editors, 16th Australian Computer Science Conference, pages 685691, Brisbane. Revised version to appear in Theoretical Computer Science.Google Scholar
Gibbons, Jeremy (1993b). Upwards and downwards accumulations on trees. In Bird, R. S., Morgan, C. C., and Woodcock, J. C. P., editors, LNCS 669: Mathematics of Program Construction, pages 122138. Springer-Verlag. A revised version appears in the Proceedings of the Massey Functional Programming Workshop, 1992.Google Scholar
Gibbons, Jeremy (1994). How to derive tidy drawings of trees. In Calude, C., Lennon, M. J. J., and Maurer, H., editors, Proceedings of Salodays in Auckland, pages 5373, Department of Computer Science, University of Auckland.Google Scholar
Gibbons, Jeremy (1995). An initial-algebra approach to directed acyclic graphs. In Möller, B., editor, LNCS 947: Mathematics of Program Construction, pages 282303. Springer-Verlag.Google Scholar
Gibbons, Jeremy (1996). The Third Homomorphism Theorem. Journal of Functional Programming 6(4).CrossRefGoogle Scholar
Gries, David (1982). A note on a standard strategy for developing loop invariants and loops. Science of Computer Programming, 2:207214.CrossRefGoogle Scholar
Kennedy, Andrew (1996). Drawing trees. Journal of Functional Programming, to appear.Google Scholar
Knuth, Donald E. (1968). The Art of Computer Programming, Volume 1: Fundamental Algorithms. Addison-Wesley.Google Scholar
Knuth, Donald E. (1971). Optimum binary search trees. Acta Informatica, 1:1425.Google Scholar
Ladner, Richard E. and Fischer, Michael J. (1980). Parallel prefix computation. Journal of the ACM, 27(4):831838.CrossRefGoogle Scholar
Malcolm, Grant (1990). Algebraic Data Types and Program Transformation. PhD thesis, Rijksuniversiteit Groningen.Google Scholar
Meertens, Lambert (1986). Algorithmics: Towards programming as a mathematical activity. In de Bakker, J. W., Hazewinkel, M., and Lenstra, J. K., editors, Proc. CWI Symposium on Mathematics and Computer Science, pages 289334. North-Holland.Google Scholar
Radack, G. M. (1988). Tidy drawing of M-ary trees. Technical Report CES-88-24, Department of Computer Engineering and Science, Case Western Reserve University, Cleveland, Ohio.Google Scholar
Reingold, Edward M. and Tilford, John S. (1981). Tidier drawings of trees. IEEE Transactions on Software Engineering, 7(2):223228.Google Scholar
Skillicorn, David B. (1993). Parallel evaluation of structured queries in text. Draft, Department of Computing and Information Sciences, Queen's University, Kingston, Ontario.Google Scholar
Supowit, Kenneth J. and Reingold, Edward M. (1983). The complexity of drawing trees nicely. Acta Informatica, 18(4):377392.CrossRefGoogle Scholar
Vaucher, Jean G. (1980). Pretty-printing of trees. Software—Practice and Experience, 10:553561.Google Scholar
Walker, John Q. II (1990). A node-positioning algorithm for general trees. Software—Practice and Experience, 20(7):685705.CrossRefGoogle Scholar
Wetherell, Charles and Shannon, Alfred (1979). Tidy drawings of trees. IEEE Transactions on Software Engineering, 5(5):514520.Google Scholar
Wirth, Niklaus (1976). Algorithms + Data Structures = Programs. Prentice Hall.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.