Class RootedTreeIsomorphism

java.lang.Object
org.graph4j.isomorphism.RootedTreeIsomorphism
All Implemented Interfaces:
IsomorphismAlgorithm

public class RootedTreeIsomorphism extends Object implements IsomorphismAlgorithm
Algorithm for testing isomorphism of rooted trees.

This algorithm is based on "Alfred V. Aho and John E. Hopcroft. 1974. The Design and Analysis of Computer Algorithms (1st ed.). Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA.", page 83-84.

Time complexity: linear in the number of vertices of the input trees. Space complexity: linear in the number of vertices of the input trees.

The trees may be either directed or undirected, but if they are directed, all edges should flow from the root (they should be arborescences).

Author:
Ignat Gabriel-Andrei, Cristian Frasinaru
  • Constructor Details

    • RootedTreeIsomorphism

      public RootedTreeIsomorphism(Graph tree1, Graph tree2, int root1, int root2)
      Constructor for the rooted tree isomorphism algorithm. It does not verify if the input graphs are actually trees.
      Parameters:
      tree1 - first tree.
      tree2 - second tree.
      root1 - root of the first tree.
      root2 - root of the second tree.
      Throws:
      NullPointerException - if either tree1 or tree2 is null.
      IllegalArgumentException - if either root1 or root2 is not in their respective trees.
    • RootedTreeIsomorphism

      public RootedTreeIsomorphism(RootedTree rootedTree1, RootedTree rootedTree2)
      Constructor for the rooted tree isomorphism algorithm. It does not verify if the input graphs are actually trees.
      Parameters:
      rootedTree1 - the first rooted tree.
      rootedTree2 - the second rooted tree.
  • Method Details