Changeset 9250
- Timestamp:
- 02/27/13 13:31:32 (12 years ago)
- Location:
- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs
r9239 r9250 105 105 symbolicExpressionTreeChart.Tree = genealogyGraphNode.SymbolicExpressionTree; 106 106 if (genealogyGraphNode.InEdges == null) return; 107 var arc = genealogyGraphNode.InEdges.First(x => x.Source != x.Target && x.Data != null);108 if (arc == null ) return;107 var arc = genealogyGraphNode.InEdges.First(x => x.Source != x.Target); 108 if (arc == null || arc.Data == null) return; 109 109 var fragment = (IFragment)arc.Data; 110 110 if (fragment.Root == null) return; -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/HeuristicLab.EvolutionaryTracking.Views-3.4.csproj
r9239 r9250 94 94 <DependentUpon>GenealogyGraphChart.cs</DependentUpon> 95 95 </Compile> 96 <Compile Include="GenealogyGraphDialog.cs" /> 96 <Compile Include="GenealogyGraphDialog.cs"> 97 <SubType>Form</SubType> 98 </Compile> 97 99 <Compile Include="GenealogyGraphDialog.designer.cs"> 98 100 <DependentUpon>GenealogyGraphDialog.cs</DependentUpon> -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.Designer.cs
r9239 r9250 51 51 // qualityImprovementTreeView 52 52 // 53 this.qualityImprovementTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 53 this.qualityImprovementTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 54 | System.Windows.Forms.AnchorStyles.Right))); 54 55 this.qualityImprovementTreeView.HideSelection = false; 55 56 this.qualityImprovementTreeView.Location = new System.Drawing.Point(388, 0); … … 61 62 // symbolicExpressionTreeChart 62 63 // 64 this.symbolicExpressionTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 65 | System.Windows.Forms.AnchorStyles.Left) 66 | System.Windows.Forms.AnchorStyles.Right))); 63 67 this.symbolicExpressionTreeChart.BackgroundColor = System.Drawing.Color.White; 64 this.symbolicExpressionTreeChart.Dock = System.Windows.Forms.DockStyle.Fill;65 68 this.symbolicExpressionTreeChart.LineColor = System.Drawing.Color.Black; 66 69 this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(155, 0); 67 70 this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart"; 68 this.symbolicExpressionTreeChart.Size = new System.Drawing.Size( 348, 624);71 this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(227, 624); 69 72 this.symbolicExpressionTreeChart.Spacing = 5; 70 73 this.symbolicExpressionTreeChart.SuspendRepaint = false; … … 96 99 // showGenealogyButton 97 100 // 98 this.showGenealogyButton.Location = new System.Drawing.Point(128, 4); 101 this.showGenealogyButton.AutoSize = true; 102 this.showGenealogyButton.Location = new System.Drawing.Point(129, 4); 99 103 this.showGenealogyButton.Name = "showGenealogyButton"; 100 104 this.showGenealogyButton.Size = new System.Drawing.Size(104, 23); … … 106 110 // calculateFragmentFrequencyButton 107 111 // 112 this.calculateFragmentFrequencyButton.AutoSize = true; 108 113 this.calculateFragmentFrequencyButton.Location = new System.Drawing.Point(4, 4); 109 114 this.calculateFragmentFrequencyButton.Name = "calculateFragmentFrequencyButton"; 110 this.calculateFragmentFrequencyButton.Size = new System.Drawing.Size(11 8, 23);115 this.calculateFragmentFrequencyButton.Size = new System.Drawing.Size(119, 23); 111 116 this.calculateFragmentFrequencyButton.TabIndex = 0; 112 117 this.calculateFragmentFrequencyButton.Text = "Fragment frequencies"; … … 124 129 this.panel1.ResumeLayout(false); 125 130 this.panel2.ResumeLayout(false); 131 this.panel2.PerformLayout(); 126 132 this.ResumeLayout(false); 127 133 -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.cs
r9239 r9250 24 24 public LineageExplorerView() { 25 25 InitializeComponent(); 26 27 26 treeMap = new Dictionary<TreeNode, ISymbolicExpressionTree>(); 28 27 } … … 45 44 base.OnContentChanged(); 46 45 if (Content == null) { 47 // TODO: Add code when content has been changed and is null48 46 } else { 49 47 var tuples = Content.Trees.OrderByDescending(x => x.Item2).ToList(); … … 57 55 scopeListTreeView.Nodes[i].ForeColor = color; 58 56 } 59 60 // TODO: Add code when content has been changed and is not null61 57 } 62 58 } … … 73 69 74 70 var graphNode = Content.GenealogyGraph.GetGraphNodes(symbExprTree).First(); 75 if (lineage == null) 76 lineage = new List<SymbolicExpressionGenealogyGraphNode> { graphNode }; 77 else 78 lineage.Clear(); 71 lineage = lineage ?? new List<SymbolicExpressionGenealogyGraphNode>(); 72 lineage.Clear(); 73 lineage.Add(graphNode); 79 74 80 75 var gn = graphNode; … … 83 78 lineage.Add(gn); 84 79 } 85 lineage.Reverse(); 80 lineage.Reverse(); // incresing order by generation 86 81 87 82 // update the righthand side tree view … … 101 96 /// that is saved as a data member in the incoming arc from the parent in the previous generation 102 97 /// </summary> 103 /// <param name=" tree"></param>98 /// <param name="symbExprTree"></param> 104 99 private void HighlightFragment(ISymbolicExpressionTree symbExprTree) { 105 100 // update the symbolic expression tree chart with the new selected tree: 101 symbolicExpressionTreeChart.SuspendRepaint = true; 106 102 symbolicExpressionTreeChart.Tree = symbExprTree; 107 103 var matchingNodes = Content.GenealogyGraph.GetGraphNodes(symbExprTree); 108 104 SymbolicExpressionGenealogyGraphNode graphNode = matchingNodes.First(); 109 110 if (graphNode.InEdges == null) return; 111 105 if (graphNode.InEdges == null) { 106 symbolicExpressionTreeChart.SuspendRepaint = false; 107 symbolicExpressionTreeChart.Repaint(); 108 return; 109 } 112 110 var fragment = (IFragment)graphNode.InEdges[0].Data; 113 if (fragment.Root == null) return; 111 if (fragment.Root == null) { 112 symbolicExpressionTreeChart.SuspendRepaint = false; 113 symbolicExpressionTreeChart.Repaint(); 114 return; 115 } 114 116 foreach (var node in fragment.Root.IterateNodesBreadth()) { 115 117 var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node); 116 118 visualNode.LineColor = Color.DodgerBlue; 117 119 } 120 symbolicExpressionTreeChart.SuspendRepaint = false; 118 121 symbolicExpressionTreeChart.Repaint(); 119 122 } … … 125 128 126 129 private void calculateFragmentFrequencyButton_Click(object sender, EventArgs e) { 127 var matchingNodes = Content.GenealogyGraph.GetGraphNodes(symbolicExpressionTreeChart.Tree); 128 SymbolicExpressionGenealogyGraphNode graphNode = matchingNodes.First(); 129 130 // var tree = symbolicExpressionTreeChart.Tree; 131 // var fragments = tree.IterateNodesPrefix().Select(node => new Fragment(node)).ToList(); 132 // 133 // var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer { 134 // MatchConstantValues = false, 135 // MatchVariableNames = true, 136 // MatchVariableWeights = false 137 // }; 138 // 139 // var dict = new Dictionary<ISymbolicExpressionTree, bool>(); 140 // 141 // var trees = Content.Trees.Select(t => t.Item1).ToList(); 142 143 144 #region oldcode 145 if (graphNode.InEdges == null) return; 146 147 var fragment = (IFragment)graphNode.InEdges[0].Data; 148 if (fragment.Root == null) return; 149 150 var fragments = new List<IFragment>(); // fragments that contain the current fragment 151 var subtree = fragment.Root; 152 153 while (subtree.Parent != null) { 154 subtree = subtree.Parent; 155 fragments.Add(new Fragment(subtree)); 156 } 157 158 fragments.Add(fragment); 159 fragments.Sort((b, a) => a.Length.CompareTo(b.Length)); 130 // the individual can occur multiple times in the graph if it is(was) elite. we take the first occurence. 131 var graphNode = Content.GenealogyGraph.GetGraphNodes(symbolicExpressionTreeChart.Tree).First(); 132 var fragments = graphNode.SymbolicExpressionTree.IterateNodesBreadth().Select(n => new Fragment(n)); 133 var trees = Content.Trees.Select(t => t.Item1).ToList(); 134 var hashset = new HashSet<ISymbolicExpressionTree>(); 160 135 161 136 var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer { … … 165 140 }; 166 141 167 // var trees = Content.GenealogyGraph.Nodes.Select(n => n.SymbolicExpressionTree).ToList(); 168 169 var trees = Content.Trees.Select(t => t.Item1).ToList(); 170 // var dictionary = new Dictionary<ISymbolicExpressionTree, bool>(trees.Count); 171 var hashset = new HashSet<ISymbolicExpressionTree>(); 172 // foreach (var tree in trees) 173 // if (!dictionary.ContainsKey(tree)) 174 // dictionary.Add(tree, false); 175 142 symbolicExpressionTreeChart.SuspendRepaint = true; 176 143 foreach (var f in fragments) { 177 double frequency = 0; 178 foreach (var tree in trees) { 179 if (hashset.Contains(tree)) frequency += 1; 180 else if (tree.Root.ContainsFragment(f, similarityComparer)) { 181 frequency += 1; 182 hashset.Add(tree); 144 double freq = 0; 145 foreach (var t in trees) { 146 if (t.Root.ContainsFragment(f, similarityComparer)) ++freq; 147 int index = (int)Math.Floor(freq * ColorGradient.Colors.Count / trees.Count); 148 if (index == ColorGradient.Colors.Count) index--; 149 var color = ColorGradient.Colors[index]; 150 foreach (var node in f.Root.IterateNodesBreadth()) { 151 var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node); 152 visualNode.FillColor = Color.FromArgb(200, color); 183 153 } 184 154 } 185 186 int index = (int)Math.Floor(frequency * ColorGradient.Colors.Count / trees.Count);187 if (index == ColorGradient.Colors.Count) index--;188 var color = ColorGradient.Colors[index];189 190 foreach (var node in f.Root.IterateNodesBreadth()) {191 var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);192 visualNode.FillColor = Color.FromArgb(200, color);193 }194 155 } 195 #endregion156 symbolicExpressionTreeChart.SuspendRepaint = false; 196 157 symbolicExpressionTreeChart.Repaint(); 197 158 } 198 159 199 160 private void symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 200 201 161 } 202 162 … … 212 172 } 213 173 using (var dialog = new GenealogyGraphDialog { Graph = graph }) { 214 // dialog.ShowDialog(); 215 dialog.Show(this); 174 dialog.ShowDialog(this); 216 175 } 217 176 }
Note: See TracChangeset
for help on using the changeset viewer.