Class RTED_InfoTree_Opt


  • public class RTED_InfoTree_Opt
    extends Object
    Computes the tree edit distance using RTED algorithm.
    Author:
    Mateusz Pawlik
    • Constructor Detail

      • RTED_InfoTree_Opt

        public RTED_InfoTree_Opt​(double delCost,
                                 double insCost,
                                 double matchCost)
        The constructor. Parameters passed are the edit operation costs.
        Parameters:
        delCost -
        insCost -
        matchCost -
    • Method Detail

      • nonNormalizedTreeDist

        public double nonNormalizedTreeDist​(LblTree t1,
                                            LblTree t2)
        Computes the tree edit distance between trees t1 and t2.
        Parameters:
        t1 -
        t2 -
        Returns:
        tree edit distance between trees t1 and t2
      • nonNormalizedTreeDist

        public double nonNormalizedTreeDist()
      • init

        public void init​(LblTree t1,
                         LblTree t2)
        Initialization method.
        Parameters:
        t1 -
        t2 -
      • computeOptimalStrategy

        public void computeOptimalStrategy()
        A method for computing and storing the optimal strategy
      • computeDistUsingStrArray

        private double computeDistUsingStrArray​(InfoTree it1,
                                                InfoTree it2)
        The recursion step according to the optimal strategy.
        Parameters:
        it1 -
        it2 -
        Returns:
      • spfL

        private double spfL​(InfoTree it1,
                            InfoTree it2)
        Single-path function for the left-most path based on Zhang and Shasha algorithm.
        Parameters:
        it1 -
        it2 -
        Returns:
        distance between subtrees it1 and it2
      • treeEditDist

        private void treeEditDist​(InfoTree it1,
                                  InfoTree it2,
                                  int i,
                                  int j)
      • spfR

        private double spfR​(InfoTree it1,
                            InfoTree it2)
        Single-path function for right-most path based on symmetric version of Zhang and Shasha algorithm.
        Parameters:
        it1 -
        it2 -
        Returns:
        distance between subtrees it1 and it2
      • treeEditDistRev

        private void treeEditDistRev​(InfoTree it1,
                                     InfoTree it2,
                                     int i,
                                     int j)
      • spfH

        private double spfH​(InfoTree it1,
                            InfoTree it2,
                            int[] heavyPath)
        Single-path function for heavy path based on Klein/Demaine algorithm.
        Parameters:
        it1 -
        it2 -
        heavyPath -
        Returns:
        distance between subtrees it1 and it2
      • computePeriod

        private void computePeriod​(InfoTree it1,
                                   int aVp,
                                   int aNextVp,
                                   InfoTree it2,
                                   int aStrategy)
        Compute period method.
        Parameters:
        it1 -
        aVp -
        aNextVp -
        it2 -
        aStrategy -
      • computeIJTable

        private void computeIJTable​(InfoTree it,
                                    int subtreePreorder,
                                    int subtreeRevPreorder,
                                    int subtreeSize,
                                    int aStrategy,
                                    int treeSize)
        Computes an array where preorder/rev.preorder of a subforest of given subtree is stored and can be accessed for given i and j.
        Parameters:
        it -
        subtreePreorder -
        subtreeRevPreorder -
        subtreeSize -
        aStrategy -
        treeSize -
      • jOfI

        private int jOfI​(InfoTree it,
                         int aI,
                         int aSubtreeWeight,
                         int aSubtreeRevPre,
                         int aSubtreePre,
                         int aStrategy,
                         int treeSize)
        Returns j for given i, result of j(i) form Demaine's algorithm.
        Parameters:
        it -
        aI -
        aSubtreeWeight -
        aSubtreeRevPre -
        aSubtreePre -
        aStrategy -
        treeSize -
        Returns:
        j for given i
      • setDeltaValue

        private void setDeltaValue​(int a,
                                   int b,
                                   double value,
                                   boolean switched)
      • setDeltaBitValue

        private void setDeltaBitValue​(int a,
                                      int b,
                                      byte value,
                                      boolean switched)
      • setCustomCosts

        public void setCustomCosts​(double costDel,
                                   double costIns,
                                   double costMatch)
      • setCustomStrategy

        public void setCustomStrategy​(int[][] strategyArray)
      • setCustomStrategy

        public void setCustomStrategy​(int strategy,
                                      boolean ifSwitch)