Changeset 11212


Ignore:
Timestamp:
07/22/14 01:54:47 (8 years ago)
Author:
bburlacu
Message:

#2215: Realized that "Height" in the paper might actually refer to the subtree depth (and not it's level in the tree). Changed code according to this interpretation as it makes more sense and seems to produce the correct results.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeDistance/BottomUpTreeDistanceCalculator.cs

    r11211 r11212  
    128128          for (int i = vertices.Count - 1; i >= 0; --i) {
    129129            var w = vertices[i];
    130             // removed requirement for heights to be equal since a compacted dag should not care about heights
    131             // this ensures correct behavior when isomorphic subtrees are placed at different depths.
    132             // furthermore, if the nodes have the same labels and the same subtrees then that should be sufficient,
    133             // since in the bottom-up approach we are guaranteed that no differences would occur on the lower levels
    134             if (v.SubtreeCount != w.OutDegree || label != w.Label)
     130            if (Height(v) != Height(w) || v.SubtreeCount != w.OutDegree || label != w.Label)
    135131              continue;
    136132
     
    192188
    193189    private static int Height(IVertex v) {
    194       return Height((ISymbolicExpressionTreeNode)v.Content);
     190      return ((ISymbolicExpressionTreeNode)v.Content).GetDepth();
    195191    }
    196192
    197193    private static int Height(ISymbolicExpressionTreeNode n) {
    198       var p = n;
    199       while (p.Parent != null)
    200         p = p.Parent;
    201       return p.GetBranchLevel(n);
     194      return n.GetDepth();
    202195    }
    203196
Note: See TracChangeset for help on using the changeset viewer.