Revisiting Tree Isomorphism: An Algorithmic Bric-à-Brac - Archive ouverte HAL Accéder directement au contenu
Pré-Publication, Document De Travail Année : 2023

Revisiting Tree Isomorphism: An Algorithmic Bric-à-Brac

Résumé

The Aho, Hopcroft and Ullman (AHU) algorithm has been the state of the art since the 1970s for determining in linear time whether two unordered rooted trees are isomorphic or not. However, it has been criticized (by Campbell and Radford) for the way it is written, which requires several (re)readings to be understood, and does not facilitate its analysis. In this article, we propose a different, more intuitive formulation of the algorithm, as well as three propositions of implementation, two using sorting algorithms and one using prime multiplication. Although none of these three variants admits linear complexity, we show that in practice two of them are competitive with the original algorithm, while being straightforward to implement. Surprisingly, the algorithm that uses multiplications of prime numbers (which are also be generated during the execution) is competitive with the fastest variants using sorts, despite having a worst theoretical complexity. We also adapt our formulation of AHU to tackle to compression of trees in directed acyclic graphs (DAGs). This algorithm is also available in three versions, two with sorting and one with prime number multiplication. Our experiments are carried out on trees of size at most $10^6$, consistent with the actual datasets we are aware of, and done in Python with the library treex, dedicated to tree algorithms.
Fichier principal
Vignette du fichier
AHU_variants-4.pdf (364.91 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-04232137 , version 1 (07-10-2023)
hal-04232137 , version 2 (13-02-2024)

Identifiants

Citer

Florian Ingels. Revisiting Tree Isomorphism: An Algorithmic Bric-à-Brac. 2023. ⟨hal-04232137v2⟩
17 Consultations
289 Téléchargements

Altmetric

Partager

Gmail Mastodon Facebook X LinkedIn More