Index: /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.cs
===================================================================
--- /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.cs	(revision 9238)
+++ /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.cs	(revision 9239)
@@ -47,4 +47,5 @@
       internal set {
         graph = value;
+        if (graph == null) return;
         // TODO: should move the subtree sorting code out of here and int the view
         var canonicalSorter = new SymbolicExpressionTreeCanonicalSorter();
@@ -172,4 +173,5 @@
 
       DrawLineage(visualNode, n => n.IncomingArcs, a => a.Source);
+      visualNode.Brush = null;
       DrawLineage(visualNode, n => n.OutgoingArcs, a => a.Target);
 
@@ -186,6 +188,8 @@
                              Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector,
                              Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) {
+      if (node.Brush != null) return;
       node.Brush = new SolidBrush(node.Data.GetColor());
       var arcs = arcSelector(node);
+      if (arcs == null) return;
       foreach (var arc in arcs) {
         var source = arc.Source.Data;
Index: /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphDialog.Designer.cs
===================================================================
--- /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphDialog.Designer.cs	(revision 9239)
+++ /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphDialog.Designer.cs	(revision 9239)
@@ -0,0 +1,56 @@
+﻿namespace HeuristicLab.EvolutionaryTracking.Views {
+  partial class GenealogyGraphDialog {
+    /// <summary>
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary>
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Windows Form Designer generated code
+
+    /// <summary>
+    /// Required method for Designer support - do not modify
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.genealogyGraphChart1 = new HeuristicLab.EvolutionaryTracking.Views.GenealogyGraphChart();
+      this.SuspendLayout();
+      // 
+      // genealogyGraphChart1
+      // 
+      this.genealogyGraphChart1.BackColor = System.Drawing.SystemColors.Control;
+      this.genealogyGraphChart1.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.genealogyGraphChart1.Location = new System.Drawing.Point(0, 0);
+      this.genealogyGraphChart1.Name = "genealogyGraphChart1";
+      this.genealogyGraphChart1.ScaleOnResize = true;
+      this.genealogyGraphChart1.Size = new System.Drawing.Size(284, 262);
+      this.genealogyGraphChart1.TabIndex = 0;
+      // 
+      // GenealogyGraphDialog
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.ClientSize = new System.Drawing.Size(284, 262);
+      this.Controls.Add(this.genealogyGraphChart1);
+      this.Cursor = System.Windows.Forms.Cursors.Default;
+      this.Name = "GenealogyGraphDialog";
+      this.Text = "Genealogy";
+      this.ResumeLayout(false);
+
+    }
+
+    #endregion
+
+    private GenealogyGraphChart genealogyGraphChart1;
+  }
+}
Index: /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphDialog.cs
===================================================================
--- /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphDialog.cs	(revision 9239)
+++ /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphDialog.cs	(revision 9239)
@@ -0,0 +1,13 @@
+﻿using System.Windows.Forms;
+
+namespace HeuristicLab.EvolutionaryTracking.Views {
+  public partial class GenealogyGraphDialog : Form {
+    public SymbolicExpressionTreeGenealogyGraph Graph {
+      set { genealogyGraphChart1.Graph = value; }
+    }
+
+    public GenealogyGraphDialog() {
+      InitializeComponent();
+    }
+  }
+}
Index: /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs
===================================================================
--- /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs	(revision 9238)
+++ /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs	(revision 9239)
@@ -108,4 +108,5 @@
       if (arc == null) return;
       var fragment = (IFragment)arc.Data;
+      if (fragment.Root == null) return;
       foreach (var node in fragment.Root.IterateNodesBreadth()) {
         var visualSymbExprTreeNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
Index: /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/HeuristicLab.EvolutionaryTracking.Views-3.4.csproj
===================================================================
--- /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/HeuristicLab.EvolutionaryTracking.Views-3.4.csproj	(revision 9238)
+++ /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/HeuristicLab.EvolutionaryTracking.Views-3.4.csproj	(revision 9239)
@@ -94,4 +94,8 @@
       <DependentUpon>GenealogyGraphChart.cs</DependentUpon>
     </Compile>
+    <Compile Include="GenealogyGraphDialog.cs" />
+    <Compile Include="GenealogyGraphDialog.designer.cs">
+      <DependentUpon>GenealogyGraphDialog.cs</DependentUpon>
+    </Compile>
     <Compile Include="GenealogyGraphView.cs">
       <SubType>UserControl</SubType>
@@ -99,4 +103,10 @@
     <Compile Include="GenealogyGraphView.Designer.cs">
       <DependentUpon>GenealogyGraphView.cs</DependentUpon>
+    </Compile>
+    <Compile Include="LineageExplorerView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="LineageExplorerView.Designer.cs">
+      <DependentUpon>LineageExplorerView.cs</DependentUpon>
     </Compile>
     <Compile Include="Plugin.cs" />
@@ -112,5 +122,5 @@
   <ItemGroup>
     <ProjectReference Include="..\..\HeuristicLab.EvolutionaryTracking\3.4\HeuristicLab.EvolutionaryTracking-3.4.csproj">
-      <Project>{1F75CEA3-464F-4A6F-B2F0-04B9841EBC16}</Project>
+      <Project>{1f75cea3-464f-4a6f-b2f0-04b9841ebc16}</Project>
       <Name>HeuristicLab.EvolutionaryTracking-3.4</Name>
     </ProjectReference>
@@ -124,6 +134,12 @@
   </ItemGroup>
   <ItemGroup>
+    <EmbeddedResource Include="GenealogyGraphDialog.resx">
+      <DependentUpon>GenealogyGraphDialog.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="GenealogyGraphView.resx">
       <DependentUpon>GenealogyGraphView.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="LineageExplorerView.resx">
+      <DependentUpon>LineageExplorerView.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="Properties\Resources.resx">
Index: /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.Designer.cs
===================================================================
--- /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.Designer.cs	(revision 9239)
+++ /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.Designer.cs	(revision 9239)
@@ -0,0 +1,146 @@
+﻿namespace HeuristicLab.EvolutionaryTracking.Views {
+  partial class LineageExplorerView {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.components = new System.ComponentModel.Container();
+      this.panel1 = new System.Windows.Forms.Panel();
+      this.qualityImprovementTreeView = new System.Windows.Forms.TreeView();
+      this.symbolicExpressionTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
+      this.scopeListTreeView = new System.Windows.Forms.TreeView();
+      this.panel2 = new System.Windows.Forms.Panel();
+      this.showGenealogyButton = new System.Windows.Forms.Button();
+      this.calculateFragmentFrequencyButton = new System.Windows.Forms.Button();
+      this.panel1.SuspendLayout();
+      this.panel2.SuspendLayout();
+      this.SuspendLayout();
+      // 
+      // panel1
+      // 
+      this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.panel1.Controls.Add(this.qualityImprovementTreeView);
+      this.panel1.Controls.Add(this.symbolicExpressionTreeChart);
+      this.panel1.Controls.Add(this.scopeListTreeView);
+      this.panel1.Location = new System.Drawing.Point(3, 42);
+      this.panel1.Name = "panel1";
+      this.panel1.Size = new System.Drawing.Size(503, 624);
+      this.panel1.TabIndex = 0;
+      // 
+      // qualityImprovementTreeView
+      // 
+      this.qualityImprovementTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+      this.qualityImprovementTreeView.HideSelection = false;
+      this.qualityImprovementTreeView.Location = new System.Drawing.Point(388, 0);
+      this.qualityImprovementTreeView.Name = "qualityImprovementTreeView";
+      this.qualityImprovementTreeView.Size = new System.Drawing.Size(115, 624);
+      this.qualityImprovementTreeView.TabIndex = 10;
+      this.qualityImprovementTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.qualityImprovementTreeView_AfterSelect);
+      // 
+      // symbolicExpressionTreeChart
+      // 
+      this.symbolicExpressionTreeChart.BackgroundColor = System.Drawing.Color.White;
+      this.symbolicExpressionTreeChart.Dock = System.Windows.Forms.DockStyle.Fill;
+      this.symbolicExpressionTreeChart.LineColor = System.Drawing.Color.Black;
+      this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(155, 0);
+      this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";
+      this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(348, 624);
+      this.symbolicExpressionTreeChart.Spacing = 5;
+      this.symbolicExpressionTreeChart.SuspendRepaint = false;
+      this.symbolicExpressionTreeChart.TabIndex = 12;
+      this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
+      this.symbolicExpressionTreeChart.Tree = null;
+      this.symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked);
+      // 
+      // scopeListTreeView
+      // 
+      this.scopeListTreeView.Dock = System.Windows.Forms.DockStyle.Left;
+      this.scopeListTreeView.HideSelection = false;
+      this.scopeListTreeView.Location = new System.Drawing.Point(0, 0);
+      this.scopeListTreeView.Name = "scopeListTreeView";
+      this.scopeListTreeView.Size = new System.Drawing.Size(155, 624);
+      this.scopeListTreeView.TabIndex = 11;
+      this.scopeListTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.scopeListTreeView_AfterSelect);
+      // 
+      // panel2
+      // 
+      this.panel2.Controls.Add(this.showGenealogyButton);
+      this.panel2.Controls.Add(this.calculateFragmentFrequencyButton);
+      this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
+      this.panel2.Location = new System.Drawing.Point(0, 0);
+      this.panel2.Name = "panel2";
+      this.panel2.Size = new System.Drawing.Size(509, 33);
+      this.panel2.TabIndex = 1;
+      // 
+      // showGenealogyButton
+      // 
+      this.showGenealogyButton.Location = new System.Drawing.Point(128, 4);
+      this.showGenealogyButton.Name = "showGenealogyButton";
+      this.showGenealogyButton.Size = new System.Drawing.Size(104, 23);
+      this.showGenealogyButton.TabIndex = 1;
+      this.showGenealogyButton.Text = "Show genealogy";
+      this.showGenealogyButton.UseVisualStyleBackColor = true;
+      this.showGenealogyButton.Click += new System.EventHandler(this.showGenealogyButton_Click);
+      // 
+      // calculateFragmentFrequencyButton
+      // 
+      this.calculateFragmentFrequencyButton.Location = new System.Drawing.Point(4, 4);
+      this.calculateFragmentFrequencyButton.Name = "calculateFragmentFrequencyButton";
+      this.calculateFragmentFrequencyButton.Size = new System.Drawing.Size(118, 23);
+      this.calculateFragmentFrequencyButton.TabIndex = 0;
+      this.calculateFragmentFrequencyButton.Text = "Fragment frequencies";
+      this.calculateFragmentFrequencyButton.UseVisualStyleBackColor = true;
+      this.calculateFragmentFrequencyButton.Click += new System.EventHandler(this.calculateFragmentFrequencyButton_Click);
+      // 
+      // LineageExplorerView
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.Controls.Add(this.panel2);
+      this.Controls.Add(this.panel1);
+      this.Name = "LineageExplorerView";
+      this.Size = new System.Drawing.Size(509, 669);
+      this.panel1.ResumeLayout(false);
+      this.panel2.ResumeLayout(false);
+      this.ResumeLayout(false);
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.Panel panel1;
+    private System.Windows.Forms.Panel panel2;
+    private System.Windows.Forms.Button calculateFragmentFrequencyButton;
+    private System.Windows.Forms.TreeView qualityImprovementTreeView;
+    private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart symbolicExpressionTreeChart;
+    private System.Windows.Forms.TreeView scopeListTreeView;
+    private System.Windows.Forms.Button showGenealogyButton;
+
+
+
+
+
+
+  }
+}
Index: /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.cs
===================================================================
--- /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.cs	(revision 9239)
+++ /branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.cs	(revision 9239)
@@ -0,0 +1,223 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Windows.Forms;
+using HeuristicLab.Common;
+using HeuristicLab.Core.Views;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.MainForm;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+
+namespace HeuristicLab.EvolutionaryTracking.Views {
+  [View("LineageExplorerView")]
+  [Content(typeof(LineageExplorer), IsDefaultView = false)]
+  public sealed partial class LineageExplorerView : ItemView {
+    private Dictionary<TreeNode, ISymbolicExpressionTree> treeMap;
+    private List<SymbolicExpressionGenealogyGraphNode> lineage;
+
+    public new LineageExplorer Content {
+      get { return (LineageExplorer)base.Content; }
+      set { base.Content = value; }
+    }
+
+    public LineageExplorerView() {
+      InitializeComponent();
+
+      treeMap = new Dictionary<TreeNode, ISymbolicExpressionTree>();
+    }
+
+    protected override void DeregisterContentEvents() {
+      // TODO: Deregister your event handlers here
+      base.DeregisterContentEvents();
+    }
+
+    protected override void RegisterContentEvents() {
+      base.RegisterContentEvents();
+      // TODO: Register your event handlers here
+    }
+
+    #region Event Handlers (Content)
+    // TODO: Put event handlers of the content here
+    #endregion
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content == null) {
+        // TODO: Add code when content has been changed and is null
+      } else {
+        var tuples = Content.Trees.OrderByDescending(x => x.Item2).ToList();
+        scopeListTreeView.Nodes.AddRange(tuples.Select(x => new TreeNode(x.Item2.ToString())).ToArray());
+
+        for (int i = 0; i != tuples.Count; ++i) {
+          treeMap.Add(scopeListTreeView.Nodes[i], tuples[i].Item1);
+          double quality = tuples[i].Item2;
+          int colorIndex = (int)Math.Floor(quality * ColorGradient.Colors.Count);
+          var color = ColorGradient.Colors[colorIndex];
+          scopeListTreeView.Nodes[i].ForeColor = color;
+        }
+
+        // TODO: Add code when content has been changed and is not null
+      }
+    }
+
+    protected override void SetEnabledStateOfControls() {
+      base.SetEnabledStateOfControls();
+      // TODO: Enable or disable controls based on whether the content is null or the view is set readonly
+    }
+
+    private void scopeListTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
+      var treeNode = scopeListTreeView.SelectedNode;
+      var symbExprTree = treeMap[treeNode];
+      HighlightFragment(symbExprTree);
+
+      var graphNode = Content.GenealogyGraph.GetGraphNodes(symbExprTree).First();
+      if (lineage == null)
+        lineage = new List<SymbolicExpressionGenealogyGraphNode> { graphNode };
+      else
+        lineage.Clear();
+
+      var gn = graphNode;
+      while (gn.InEdges != null && gn.InEdges.Count != 0) {
+        gn = (SymbolicExpressionGenealogyGraphNode)gn.InEdges[0].Source;
+        lineage.Add(gn);
+      }
+      lineage.Reverse();
+
+      // update the righthand side tree view 
+      qualityImprovementTreeView.Nodes.Clear();
+      for (int i = 0; i != lineage.Count; ++i) {
+        var node = new TreeNode(string.Format("Generation {0}", lineage[i].Rank));
+        qualityImprovementTreeView.Nodes.Add(node);
+        var quality = lineage[i].Quality;
+        int colorIndex = (int)Math.Floor(quality * ColorGradient.Colors.Count);
+        var color = ColorGradient.Colors[colorIndex];
+        node.ForeColor = color;
+      }
+    }
+
+    /// <summary>
+    /// Given a symbolic expression tree, find the corresponding vertex in the genealogy graph, and highlight the fragment
+    /// that is saved as a data member in the incoming arc from the parent in the previous generation
+    /// </summary>
+    /// <param name="tree"></param>
+    private void HighlightFragment(ISymbolicExpressionTree symbExprTree) {
+      // update the symbolic expression tree chart with the new selected tree:
+      symbolicExpressionTreeChart.Tree = symbExprTree;
+      var matchingNodes = Content.GenealogyGraph.GetGraphNodes(symbExprTree);
+      SymbolicExpressionGenealogyGraphNode graphNode = matchingNodes.First();
+
+      if (graphNode.InEdges == null) return;
+
+      var fragment = (IFragment)graphNode.InEdges[0].Data;
+      if (fragment.Root == null) return;
+      foreach (var node in fragment.Root.IterateNodesBreadth()) {
+        var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
+        visualNode.LineColor = Color.DodgerBlue;
+      }
+      symbolicExpressionTreeChart.Repaint();
+    }
+
+    private void qualityImprovementTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
+      var tree = lineage[qualityImprovementTreeView.SelectedNode.Index].SymbolicExpressionTree;
+      HighlightFragment(tree);
+    }
+
+    private void calculateFragmentFrequencyButton_Click(object sender, EventArgs e) {
+      var matchingNodes = Content.GenealogyGraph.GetGraphNodes(symbolicExpressionTreeChart.Tree);
+      SymbolicExpressionGenealogyGraphNode graphNode = matchingNodes.First();
+
+      //      var tree = symbolicExpressionTreeChart.Tree;
+      //      var fragments = tree.IterateNodesPrefix().Select(node => new Fragment(node)).ToList();
+      //
+      //      var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer {
+      //        MatchConstantValues = false,
+      //        MatchVariableNames = true,
+      //        MatchVariableWeights = false
+      //      };
+      //
+      //      var dict = new Dictionary<ISymbolicExpressionTree, bool>();
+      //
+      //      var trees = Content.Trees.Select(t => t.Item1).ToList();
+
+
+      #region oldcode
+      if (graphNode.InEdges == null) return;
+
+      var fragment = (IFragment)graphNode.InEdges[0].Data;
+      if (fragment.Root == null) return;
+
+      var fragments = new List<IFragment>(); // fragments that contain the current fragment
+      var subtree = fragment.Root;
+
+      while (subtree.Parent != null) {
+        subtree = subtree.Parent;
+        fragments.Add(new Fragment(subtree));
+      }
+
+      fragments.Add(fragment);
+      fragments.Sort((b, a) => a.Length.CompareTo(b.Length));
+
+      var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer {
+        MatchConstantValues = false,
+        MatchVariableNames = true,
+        MatchVariableWeights = false
+      };
+
+      //      var trees = Content.GenealogyGraph.Nodes.Select(n => n.SymbolicExpressionTree).ToList();
+
+      var trees = Content.Trees.Select(t => t.Item1).ToList();
+      //      var dictionary = new Dictionary<ISymbolicExpressionTree, bool>(trees.Count);
+      var hashset = new HashSet<ISymbolicExpressionTree>();
+      //      foreach (var tree in trees)
+      //        if (!dictionary.ContainsKey(tree))
+      //          dictionary.Add(tree, false);
+
+      foreach (var f in fragments) {
+        double frequency = 0;
+        foreach (var tree in trees) {
+          if (hashset.Contains(tree)) frequency += 1;
+          else if (tree.Root.ContainsFragment(f, similarityComparer)) {
+            frequency += 1;
+            hashset.Add(tree);
+          }
+        }
+
+        int index = (int)Math.Floor(frequency * ColorGradient.Colors.Count / trees.Count);
+        if (index == ColorGradient.Colors.Count) index--;
+        var color = ColorGradient.Colors[index];
+
+        foreach (var node in f.Root.IterateNodesBreadth()) {
+          var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
+          visualNode.FillColor = Color.FromArgb(200, color);
+        }
+      }
+      #endregion
+      symbolicExpressionTreeChart.Repaint();
+    }
+
+    private void symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
+
+    }
+
+    private void showGenealogyButton_Click(object sender, EventArgs e) {
+      var tree = symbolicExpressionTreeChart.Tree;
+      if (tree == null) return;
+      var graphNode = Content.GenealogyGraph.GetGraphNodes(tree).First();
+
+      var graph = new SymbolicExpressionTreeGenealogyGraph();
+      var ancestors = graphNode.Ancestors();
+      foreach (var ancestorNode in ancestors) {
+        graph.AddNode(ancestorNode);
+      }
+      using (var dialog = new GenealogyGraphDialog { Graph = graph }) {
+        //        dialog.ShowDialog();
+        dialog.Show(this);
+      }
+    }
+
+    #region Event Handlers (child controls)
+    // TODO: Put event handlers of child controls here.
+    #endregion
+  }
+}
