Behavior Research Methods, Instruments, & Computers 1984, 16 (4), 405 GRAFT: A LISP program for comparing long-term memory structures revealed through ordered trees STEPHEN C. HIRTLE State University of New York, Albany, New York An algorithm for comparing ordered trees has been developed. Ordered trees have proved useful in de- scribing memory structures as revealed by free recall (McKeithen, Reitman, Rueter, & Hirtle, 1981; Reitman & Rueter, 1980). These trees differ from ordinary rooted trees derived using traditional cluster-analysis methods (e.g., Johnson, 1967) in that the branches of a node, at any level, may be restricted to a specific order- ing. Ordered trees have proved useful in describing long-term memory organization and have been shown to be applicable to many domains. In addition to denoting the structure of an individual subject, it is often useful to compare structures across time or across subjects (Hirtle, 1982). This is accom- plished most easily by comparing the chunk lattice corresponding to a tree. A chunk consists of any set of items that are consistently recalled together, regardless of order. Together, the set of chunks form a lattice (Birkhoff, 1967) of overlapping orders. A measure of dissimilarity between any two ordered trees can then be constructed by dividing the number of chunks in com- mon by the total number of unique chunks (see McKeithen et al., 1981, for further discussion of this technique). The number of chunks in the lattice of ordered trees can be large and, as a result, very tedious to construct. A LISP program has been developed to calculate and com- pare the chunk elements for the set of ordered trees. The program will compare all pairs of trees or all trees from one set with another (not necessarily distinct) set. Algorithm. The algorithm recursively generates chunks beginning with the top node of the tree, using a breadth-first construction pattern. Although designed for use with the Reitman-Rueter (1980) ordered-tree algorithm, the program can also be used to denote and I would like to thank Henry Rueter for help in developing the algorithm and Michael Mascolo for assistance in the docu- mentation. Correspondence should be addressed to Stephen C. Hirtle, Department of Psychology, State University of New York, 1400 Washington Avenue, Albany, NY 12222. compare subsets of PQ-trees developed by Booth and Lueker (1976; see also Go1umbic, 1980) to represent classes of permutations that contain consecutive sub- sequences. PQ-trees are important in the fields of graph theory and computer science, particularly for the topic of data-base structures. Input. The program is command-based; it offers five commands for entering and comparing data. After a READ command, trees are entered, with single letters or symbols being used to represent items in the tree. Bracket notation is used to denote level of the hierarchy and type of node, and a period is used to signal the end of each tree. Termination of input is done by a single period. Data can be read from a file or from the key- board. Output. The program first prints all chunk elements for each tree. The program then compares all pairs of trees and prints the number of chunks in the union and intersection set and the derived similarity measure. These numerical quantities are also written to a me for later analyses. Language and Availability. The program is available in MTS LISP, which is based on MIT MACLISP. Notes on conversion from MTS LISP to alternate dialects will be provided. The program is available as a card deck with listing for $6.00 to cover postage and reproduction costs. The program has been implemented successfully on an Amdahl 470V/6, which is a mainframe computer that is compatible with IBM System/370 computers. REFERENCES BIRKHOFF, G. (1967). Lattice theory (3rd ed.). Providence, RI: American Mathematical Society. BOOTH, K. S., & LUEKER, G. S. (1976). Testing for the consec- utive ones property, interval graphs, and graph planarity using PQ-tree algorithms. Journal of Computer and System Sciences, 13,335-379. GOLUMBIC, M. C. (1980). Algorithmic graph theory and perfect graphs. New York: Academic Press. HIRTLE, S. C. (1982). Lattice-based similarity measures between ordered trees. Journal of Mathematical Psychology, 25, 206-223. JOHNSON, S. C. (1%7). Hierarchical clustering schemes. Psycho- metrika, 32, 241-254. McKEITHEN, K. B., REITMAN, J. S., RUETER, H. R., & HIRTLE, S. C. (1981). Knowledge organization and skill differences in computer programmers. Cognitive Psychology, 13,307-325. REITMAN, J. S., & RUETER, H. R. (1980). Organization revealed by recall orders and confirmed by pauses. Cognitive Psychology, 12, 554-581. (Manuscript accepted for publication June 8,1984.) 405 Copyright 1984 Psychonomic Society, Inc.