Class RTED_InfoTree_Opt
- java.lang.Object
-
- com.crawljax.stateabstractions.dom.RTED.RTED_InfoTree_Opt
-
public class RTED_InfoTree_Opt extends Object
Computes the tree edit distance using RTED algorithm.- Author:
- Mateusz Pawlik
-
-
Field Summary
Fields Modifier and Type Field Description private static byteBOTHprivate doublecostDelprivate doublecostInsprivate doublecostMatchprivate long[][][]costVprivate long[][]costWlongcounterprivate doubledaprivate doubledbprivate doubledcprivate double[][]deltaprivate byte[][]deltaBitprivate static byteHEAVYprivate int[][]IJprivate InfoTreeit1private InfoTreeit2private static byteKRprivate static byteLEFTprivate static bytePOST2_DESC_SUMprivate static bytePOST2_KR_SUMprivate static bytePOST2_LABELprivate static bytePOST2_LLDprivate static bytePOST2_MIN_KRprivate static bytePOST2_PARENTprivate static bytePOST2_PREprivate static bytePOST2_REV_KR_SUMprivate static bytePOST2_SIZEprivate static bytePOST2_STRATEGYprivate static bytePRE2_POSTprivate intpreviousStrategyprivate static byteREVHEAVYprivate static byteREVLEFTprivate static byteREVRIGHTprivate static byteRIGHTprivate static byteRKRprivate static byteRPOST2_MIN_RKRprivate static byteRPOST2_POSTprivate static byteRPOST2_RLDprivate intsize1private intsize2private int[][]STRint[]strStatprivate double[][]t
-
Constructor Summary
Constructors Constructor Description RTED_InfoTree_Opt(double delCost, double insCost, double matchCost)The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private doublecomputeDistUsingStrArray(InfoTree it1, InfoTree it2)The recursion step according to the optimal strategy.private voidcomputeIJTable(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.voidcomputeOptimalStrategy()A method for computing and storing the optimal strategyprivate voidcomputePeriod(InfoTree it1, int aVp, int aNextVp, InfoTree it2, int aStrategy)Compute period method.voidinit(LblTree t1, LblTree t2)Initialization method.private intjOfI(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.doublenonNormalizedTreeDist()doublenonNormalizedTreeDist(LblTree t1, LblTree t2)Computes the tree edit distance between trees t1 and t2.voidsetCustomCosts(double costDel, double costIns, double costMatch)voidsetCustomStrategy(int[][] strategyArray)voidsetCustomStrategy(int strategy, boolean ifSwitch)private voidsetDeltaBitValue(int a, int b, byte value, boolean switched)private voidsetDeltaValue(int a, int b, double value, boolean switched)private doublespfH(InfoTree it1, InfoTree it2, int[] heavyPath)Single-path function for heavy path based on Klein/Demaine algorithm.private doublespfL(InfoTree it1, InfoTree it2)Single-path function for the left-most path based on Zhang and Shasha algorithm.private doublespfR(InfoTree it1, InfoTree it2)Single-path function for right-most path based on symmetric version of Zhang and Shasha algorithm.private voidtreeEditDist(InfoTree it1, InfoTree it2, int i, int j)private voidtreeEditDistRev(InfoTree it1, InfoTree it2, int i, int j)
-
-
-
Field Detail
-
LEFT
private static final byte LEFT
- See Also:
- Constant Field Values
-
RIGHT
private static final byte RIGHT
- See Also:
- Constant Field Values
-
HEAVY
private static final byte HEAVY
- See Also:
- Constant Field Values
-
BOTH
private static final byte BOTH
- See Also:
- Constant Field Values
-
REVLEFT
private static final byte REVLEFT
- See Also:
- Constant Field Values
-
REVRIGHT
private static final byte REVRIGHT
- See Also:
- Constant Field Values
-
REVHEAVY
private static final byte REVHEAVY
- See Also:
- Constant Field Values
-
POST2_SIZE
private static final byte POST2_SIZE
- See Also:
- Constant Field Values
-
POST2_KR_SUM
private static final byte POST2_KR_SUM
- See Also:
- Constant Field Values
-
POST2_REV_KR_SUM
private static final byte POST2_REV_KR_SUM
- See Also:
- Constant Field Values
-
POST2_DESC_SUM
private static final byte POST2_DESC_SUM
- See Also:
- Constant Field Values
-
POST2_PRE
private static final byte POST2_PRE
- See Also:
- Constant Field Values
-
POST2_PARENT
private static final byte POST2_PARENT
- See Also:
- Constant Field Values
-
POST2_LABEL
private static final byte POST2_LABEL
- See Also:
- Constant Field Values
-
KR
private static final byte KR
- See Also:
- Constant Field Values
-
POST2_LLD
private static final byte POST2_LLD
- See Also:
- Constant Field Values
-
POST2_MIN_KR
private static final byte POST2_MIN_KR
- See Also:
- Constant Field Values
-
RKR
private static final byte RKR
- See Also:
- Constant Field Values
-
RPOST2_RLD
private static final byte RPOST2_RLD
- See Also:
- Constant Field Values
-
RPOST2_MIN_RKR
private static final byte RPOST2_MIN_RKR
- See Also:
- Constant Field Values
-
RPOST2_POST
private static final byte RPOST2_POST
- See Also:
- Constant Field Values
-
POST2_STRATEGY
private static final byte POST2_STRATEGY
- See Also:
- Constant Field Values
-
PRE2_POST
private static final byte PRE2_POST
- See Also:
- Constant Field Values
-
counter
public long counter
-
strStat
public final int[] strStat
-
it1
private InfoTree it1
-
it2
private InfoTree it2
-
size1
private int size1
-
size2
private int size2
-
STR
private int[][] STR
-
delta
private double[][] delta
-
deltaBit
private byte[][] deltaBit
-
t
private double[][] t
-
IJ
private int[][] IJ
-
costV
private long[][][] costV
-
costW
private long[][] costW
-
da
private double da
-
db
private double db
-
dc
private double dc
-
previousStrategy
private int previousStrategy
-
costDel
private double costDel
-
costIns
private double costIns
-
costMatch
private double costMatch
-
-
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()
-
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
-
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
-
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)
-
-