Changeset 11215
- Timestamp:
- 07/22/14 12:42:20 (10 years ago)
- Location:
- branches/HeuristicLab.BottomUpTreeDistance
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.BottomUpTreeDistance.sln
r11211 r11215 5 5 MinimumVisualStudioVersion = 10.0.40219.1 6 6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj", "{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}" 7 EndProject 8 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{296A2ED3-637A-4E1E-8C06-170651BF1F04}" 9 ProjectSection(SolutionItems) = preProject 10 Performance1.psess = Performance1.psess 11 EndProjectSection 7 12 EndProject 8 13 Global … … 32 37 HideSolutionNode = FALSE 33 38 EndGlobalSection 39 GlobalSection(Performance) = preSolution 40 HasPerformanceSessions = true 41 EndGlobalSection 34 42 EndGlobal -
branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimilarityCalculator.cs
r11211 r11215 39 39 private const string MatchConstantValuesParameterName = "MatchConstantValues"; 40 40 41 private ISymbolicExpressionTreeDistanceCalculator distanceCalculator;41 private readonly ISymbolicExpressionTreeDistanceCalculator distanceCalculator; 42 42 43 43 public IScopeTreeLookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { -
branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeDistance/BottomUpTreeDistanceCalculator.cs
r11212 r11215 26 26 using System.Linq; 27 27 using System.Text; 28 using System.Text.RegularExpressions;29 28 using HeuristicLab.Common; 30 29 using HeuristicLab.Core; … … 94 93 private static Dictionary<ISymbolicExpressionTreeNode, IVertex> Compact(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) { 95 94 var nodesToVertices = new Dictionary<ISymbolicExpressionTreeNode, IVertex>(); // K 96 var disjointUnion = new DisjointUnion(t1, t2); // F97 95 var labelsToVertices = new Dictionary<string, IVertex>(); // L 98 96 var childrenCount = new Dictionary<ISymbolicExpressionTreeNode, int>(); // Children 99 97 var vertices = new List<IVertex>(); // G 100 101 var nodes = disjointUnion.Nodes.ToList(); 98 var nodes = t1.IterateNodesPostfix().Concat(t2.IterateNodesPostfix()); // the disjoint union F 102 99 103 100 // for all leaf labels l in F … … 125 122 } else { 126 123 bool found = false; 124 var height = Height(v); 127 125 // for all nodes w in G in reverse order 128 126 for (int i = vertices.Count - 1; i >= 0; --i) { 129 127 var w = vertices[i]; 130 if ( Height(v)!= Height(w) || v.SubtreeCount != w.OutDegree || label != w.Label)128 if (height != Height(w) || v.SubtreeCount != w.OutDegree || label != w.Label) 131 129 continue; 132 130 … … 182 180 } 183 181 184 185 182 private static string Label(ISymbolicExpressionTreeNode n) { 186 183 return n.ToString(); … … 195 192 } 196 193 197 private class DisjointUnion : Tuple<ISymbolicExpressionTree, ISymbolicExpressionTree> { 198 public DisjointUnion(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) 199 : base(t1, t2) { 200 } 201 202 public IEnumerable<ISymbolicExpressionTreeNode> Nodes { 203 get { return Item1.Root.IterateNodesPostfix().Concat(Item2.Root.IterateNodesPostfix()); } 204 } 205 } 206 207 public static string RemoveFirstLines(string text, int linesCount) { 208 var lines = Regex.Split(text, "\r\n|\r|\n").Skip(linesCount); 209 return string.Join(Environment.NewLine, lines.ToArray()); 210 } 211 194 // this is here for debugging purposes only 212 195 // draw the mapping between t1 and t2 as a tikz picture 213 196 private static string FormatMapping(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2, Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> map) {
Note: See TracChangeset
for help on using the changeset viewer.