Ignore:
Timestamp:
09/11/12 16:45:51 (12 years ago)
Author:
pharms
Message:
  • improved node equality comparison to match the principle of lexical, syntactical and semantical node equality. As a result, more condensed task trees are created.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/nodeequality/SequenceComparisonRule.java

    r655 r807  
    4444        } 
    4545 
     46        if (node1 == node2) { 
     47            return NodeEquality.IDENTICAL; 
     48        } 
     49 
    4650        // if both sequences do not have children, they are equal although this doesn't make sense 
    4751        if ((node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) { 
     
    4953        } 
    5054 
    51         //  
    5255        if (node1.getChildren().size() != node2.getChildren().size()) { 
    53             return null; 
     56            return NodeEquality.UNEQUAL; 
    5457        } 
    5558 
     59        NodeEquality resultingEquality = NodeEquality.LEXICALLY_EQUAL; 
    5660        for (int i = 0; i < node1.getChildren().size(); i++) { 
    5761            ITaskTreeNode child1 = node1.getChildren().get(i); 
     
    6064            NodeEquality nodeEquality = mRuleManager.applyRules(child1, child2); 
    6165 
    62             if (!nodeEquality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)) { 
    63                 return null; 
     66            if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) { 
     67                return NodeEquality.UNEQUAL; 
    6468            } 
     69             
     70            resultingEquality = resultingEquality.getCommonDenominator(nodeEquality); 
    6571        } 
    6672 
    67         return NodeEquality.LEXICALLY_EQUAL; 
     73        return resultingEquality; 
    6874    } 
    6975 
Note: See TracChangeset for help on using the changeset viewer.