Changeset 7792 for branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views
- Timestamp:
- 05/10/12 17:17:14 (12 years ago)
- Location:
- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.cs
r7785 r7792 114 114 style = DashStyle.Dash; 115 115 } else { 116 style = arc.OperatorType == 0? DashStyle.Solid : DashStyle.Dash;116 style = node.InEdges.Count == 2 ? DashStyle.Solid : DashStyle.Dash; 117 117 } 118 118 var arcPen = new Pen(Color.Transparent) { DashStyle = style }; … … 183 183 var end = new Point((int)arc.End.X, (int)arc.End.Y); 184 184 arc.Pen.Brush = new LinearGradientBrush(start, end, arc.Source.ToColor(), arc.Target.ToColor()); 185 if (node.Data.CutpointIndex == -1) {186 // if the cut index wasn't computed yet187 var parent = arc.Source.Data.Data as ISymbolicExpressionTree;188 var child = node.Data.Data as ISymbolicExpressionTree;189 node.Data.CutpointIndex = GetCutIndex(parent, child);190 }191 185 } 192 186 } … … 236 230 Chart.EnforceUpdate(); 237 231 } 238 239 // maybe this method does't belong here240 // TODO: find a good location for this kind of functionality241 private static int GetCutIndex(ISymbolicExpressionTree parent, ISymbolicExpressionTree child) {242 var e1 = parent.IterateNodesPostfix().GetEnumerator();243 var e2 = child.IterateNodesPostfix().GetEnumerator();244 int pos = 0;245 var comparer = new SymbolicExpressionTreeNodeComparer((int)SymbolicExpressionTreeMatching.SimilarityLevel.Exact);246 while (e1.MoveNext() && e2.MoveNext() && comparer.Equals(e1.Current, e2.Current)) ++pos;247 if (pos == 0) return -1;248 if (pos == child.Length) return 0;249 return pos;250 //return pos == 0 ? -1 : pos;251 }252 232 } 253 233 } -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs
r7785 r7792 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 24 25 using System.Linq; … … 92 93 symbolicExpressionTreeChart.Tree = (ISymbolicExpressionTree)genealogyGraphNode.Data; 93 94 if (_selectedVisualSymbolicExpressionTreeNode != null) { 94 var nodes = symbolicExpressionTreeChart.Tree.IterateNodes Postfix().ToArray();95 var fragments = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode.IterateNodes Postfix().ToArray();95 var nodes = symbolicExpressionTreeChart.Tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>; 96 var fragments = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>; 96 97 int index = SymbolicExpressionTreeMatching.FindMatch(nodes, fragments, similarityModeSelector.SelectedIndex); 97 98 if (index != -1) { 98 _selectedVisualSymbolicExpressionTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(nodes[index + fragments.Count ()- 1]);99 _selectedVisualSymbolicExpressionTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(nodes[index + fragments.Count - 1]); 99 100 var subtree = _selectedVisualSymbolicExpressionTreeNode.SymbolicExpressionTreeNode; 100 101 foreach (var visualNode in subtree.IterateNodesPostfix().Select(node => symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node))) { … … 104 105 } 105 106 } 106 // the cutpoint index represents the index of the node/subtree (when the tree is enumerated in postfix order) 107 // that was changed (by mutation) or received from a parent (by crossover) 108 if (visualGenealogyGraphNode.Data.CutpointIndex != -1) { 109 var gNode = visualGenealogyGraphNode.Data; 110 var symbExprTree = gNode.Data as ISymbolicExpressionTree; 111 if (symbExprTree == null) return; 112 var nodes = symbExprTree.IterateNodesPostfix(); 113 var fragment = nodes.ElementAt(gNode.CutpointIndex); 114 if (fragment != null) foreach (var node in fragment.IterateNodesPostfix()) { 115 var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node); 116 visualNode.FillColor = Color.LightPink; 117 } 118 symbolicExpressionTreeChart.Repaint(); 119 } 107 // what's left to be done here is to: 108 // - get the symbolic expression tree 109 // - get the corresponding fragment 110 // - for all symbolic expression tree nodes in the fragment, colorize the corresponding visual nodes 111 // - repaint the tree 120 112 } 121 113
Note: See TracChangeset
for help on using the changeset viewer.