A Memory-Efficient Tree Edit Distance Algorithm

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8644)


Hierarchical data are often modelled as trees. An interesting query identifies pairs of similar trees. The standard approach to tree similarity is the tree edit distance, which has successfully been applied in a wide range of applications. In terms of runtime, the state-of-the-art for the tree edit distance is the RTED algorithm, which is guaranteed to be fast independently of the tree shape. Unfortunately, this algorithm uses twice the memory of the other, slower algorithms. The memory is quadratic in the tree size and is a bottleneck for the tree edit distance computation.

In this paper we present a new, memory efficient algorithm for the tree edit distance. Our algorithm runs at least as fast as RTED, but requires only half the memory. This is achieved by systematically releasing memory early during the first step of the algorithm, which computes a decomposition strategy and is the main memory bottleneck. We show the correctness of our approach and prove an upper bound for the memory usage. Our empirical evaluation confirms the low memory requirements and shows that in practice our algorithm performs better than the analytic guarantees suggest.


Tree Size Memory Usage Strategy Computation Distance Computation Operation Sequence 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Akutsu, T.: Tree edit distance problems: Algorithms and applications to bioinformatics. IEICE Trans. on Inf. Syst. 93-D(2), 208–218 (2010)CrossRefMathSciNetGoogle Scholar
  2. 2.
    Aoki, K.F., Yamaguchi, A., Okuno, Y., Akutsu, T., Ueda, N., Kanehisa, M., Mamitsuka, H.: Efficient tree-matching methods for accurate carbohydrate database queries. Genome Informatics 14, 134–143 (2003)Google Scholar
  3. 3.
    Augsten, N., Barbosa, D., Böhlen, M., Palpanas, T.: Efficient top-k approximate subtree matching in small memory. IEEE TKDE 23(8), 1123–1137 (2011)Google Scholar
  4. 4.
    Augsten, N., Böhlen, M.H., Gamper, J.: The pq-gram distance between ordered labeled trees. ACM TODS 35(1) (2010)Google Scholar
  5. 5.
    Chawathe, S.S.: Comparing hierarchical data in external memory. In: VLDB, pp. 90–101 (1999)Google Scholar
  6. 6.
    Cobena, G., Abiteboul, S., Marian, A.: Detecting changes in XML documents. In: ICDE, pp. 41–52 (2002)Google Scholar
  7. 7.
    Cohen, S.: Indexing for subtree similarity-search using edit distance. In: SIGMOD, pp. 49–60 (2013)Google Scholar
  8. 8.
    Dalamagas, T., Cheng, T., Winkel, K.-J., Sellis, T.K.: A methodology for clustering XML documents by structure. Inf. Syst. 31(3), 187–228 (2006)CrossRefGoogle Scholar
  9. 9.
    Demaine, E.D., Mozes, S., Rossman, B., Weimann, O.: An optimal decomposition algorithm for tree edit distance. ACM Trans. on Alg. 6(1) (2009)Google Scholar
  10. 10.
    Dulucq, S., Touzet, H.: Decomposition algorithms for the tree edit distance problem. J. Discrete Alg. 3(2-4), 448–471 (2005)zbMATHMathSciNetGoogle Scholar
  11. 11.
    Finis, J.P., Raiber, M., Augsten, N., Brunel, R., Kemper, A., Färber, F.: RWS-Diff: Flexible and efficient change detection in hierarchical data. In: CIKM, pp. 339–348 (2013)Google Scholar
  12. 12.
    Garofalakis, M., Kumar, A.: XML stream processing using tree-edit distance embeddings. ACM TODS 30(1), 279–332 (2005)CrossRefGoogle Scholar
  13. 13.
    Guha, S., Jagadish, H.V., Koudas, N., Srivastava, D., Yu, T.: Approximate XML joins. In: SIGMOD, pp. 287–298 (2002)Google Scholar
  14. 14.
    Heumann, H., Wittum, G.: The tree-edit-distance, a measure for quantifying neuronal morphology. BMC Neuroscience 10(suppl. 1), P89 (2009)CrossRefGoogle Scholar
  15. 15.
    Klein, P.N.: Computing the edit-distance between unrooted ordered trees. In: Bilardi, G., Pietracaprina, A., Italiano, G.F., Pucci, G. (eds.) ESA 1998. LNCS, vol. 1461, pp. 91–102. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  16. 16.
    Korn, F., Saha, B., Srivastava, D., Ying, S.: On repairing structural problems in semi-structured data. Proceedings of the VLDB Endowment 6(9) (2013)Google Scholar
  17. 17.
    Lee, K.-H., Choy, Y.-C., Cho, S.-B.: An efficient algorithm to compute differences between structured documents. IEEE TKDE 16(8), 965–979 (2004)Google Scholar
  18. 18.
    Lin, Z., Wang, H., McClean, S.: Measuring tree similarity for natural language processing based information retrieval. In: Hopfe, C.J., Rezgui, Y., Métais, E., Preece, A., Li, H. (eds.) NLDB 2010. LNCS, vol. 6177, pp. 13–23. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  19. 19.
    Pawlik, M., Augsten, N.: RTED: A robust algorithm for the tree edit distance. Proceedings of the VLDB Endowment, 334–345 (2011)Google Scholar
  20. 20.
    Springel, V., White, S.D.M., Jenkins, A., Frenk, C.S., Yoshida, N., Gao, L., Navarro, J., Thacker, R., Croton, D., Helly, J., Peacock, J.A., Cole, S., Thomas, P., Couchman, H., Evrard, A., Colberg, J., Pearce, F.: Simulations of the formation, evolution and clustering of galaxies and quasars. Nature 435 (2005)Google Scholar
  21. 21.
    Tai, K.-C.: The tree-to-tree correction problem. J. ACM 26(3), 422–433 (1979)CrossRefzbMATHMathSciNetGoogle Scholar
  22. 22.
    Zhang, K.: Algorithms for the constrained editing distance between ordered labeled trees and related problems. Pattern Recognition 28(3), 463–474 (1995)CrossRefGoogle Scholar
  23. 23.
    Zhang, K., Shasha, D.: Simple fast algorithms for the editing distance between trees and related problems. SIAM J. Comput. 18(6), 1245–1262 (1989)CrossRefzbMATHMathSciNetGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  1. 1.University of SalzburgAustria

Personalised recommendations