Changeset 11016
- Timestamp:
- 06/15/14 23:52:13 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Formatters/SymbolicExpressionTreeLatexFormatter.cs
r11015 r11016 95 95 var coord = nodeCoordinates[node]; 96 96 var nodeName = symbolNameMap.ContainsKey(node.Symbol.Name) ? symbolNameMap[node.Symbol.Name] : node.ToString(); 97 sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1} + {2},\\hs*{3}) {{{4}}};", nodeIds[node], ws * coord.X, offset, -hs * coord.Y, EscapeLatexString(nodeName)));97 sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1} + \\offs,\\hs*{2}) {{{3}}};", nodeIds[node], ws * coord.X, -hs * coord.Y, EscapeLatexString(nodeName))); 98 98 } 99 99 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeDistance/BottomUpDistanceCalculator.cs
r11015 r11016 40 40 foreach (var l in F.Nodes.Where(x => x.SubtreeCount == 0)) { 41 41 var z = new Vertex { Content = l, Label = Label(l) }; 42 z.Weight = Height(l); // might be necessary 43 L[z.Label] = z; 42 // z.Weight = Height(l); // might be necessary (although not specified in the paper) 43 // if (!L.ContainsKey(z.Label)) 44 L[z.Label] = z; // will overwrite key values, possible bug 44 45 G.AddVertex(z); 45 46 } … … 51 52 } 52 53 } 53 do{54 while (Q.Any()) { 54 55 var v = Q.Dequeue(); 55 56 if (v.SubtreeCount == 0) { … … 61 62 if (Height(v) != Height(w) || v.SubtreeCount != w.OutDegree || Label(v) != w.Label) 62 63 break; 64 63 65 // sort the lists before comparison, as required when dealing with unordered trees 64 var V = v.Subtrees. OrderBy(Label).Select(s => K[s]);66 var V = v.Subtrees.Select(s => K[s]).OrderBy(x => x.Label); 65 67 var W = w.OutArcs.Select(x => x.Target).OrderBy(x => x.Label); 66 68 if (V.SequenceEqual(W)) { … … 73 75 if (!found) { 74 76 var w = new Vertex { Content = v, Label = Label(v), Weight = Height(v) }; 77 G.AddVertex(w); 75 78 K[v] = w; 76 79 … … 87 90 } // 47: end if 88 91 } // 48: end if 89 } while (Q.Count != 0);92 }; 90 93 return K; 91 94 } … … 168 171 169 172 public IEnumerable<ISymbolicExpressionTreeNode> Nodes { 170 get { return Item1.IterateNodesPrefix().Concat(Item2.IterateNodesPrefix()); } 173 get { 174 var nodes1 = Item1.Root.IterateNodesBreadth().Reverse(); 175 var nodes2 = Item2.Root.IterateNodesBreadth().Reverse(); 176 177 return nodes1.Concat(nodes2); 178 179 // var nodes = 180 // nodes1.Select(n => new { Node = n, Height = Item1.Root.GetBranchLevel(n) }) 181 // .Concat(nodes2.Select(n => new { Node = n, Height = Item2.Root.GetBranchLevel(n) })) 182 // .OrderByDescending(x => x.Height) 183 // .Select(x => x.Node); 184 // 185 // return nodes; 186 // // var list = new List<ISymbolicExpressionTreeNode> { Item1.Root, Item2.Root }; 187 // // int i = 0; 188 // // while (i != list.Count) { 189 // // var node = list[i]; 190 // // if (node.SubtreeCount > 0) { 191 // // list.AddRange(node.Subtrees); 192 // // } 193 // // ++i; 194 // // } 195 // // list.Reverse(); // return nodes in order of decreasing height 196 // // return list; 197 } 171 198 } 172 199
Note: See TracChangeset
for help on using the changeset viewer.