Index: /branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs
===================================================================
--- /branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs	(revision 11865)
+++ /branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/TraceCalculator.cs	(revision 11866)
@@ -35,5 +35,5 @@
   public class TraceCalculator : Item {
     private IGenealogyGraph<ISymbolicExpressionTree> traceGraph;
-    private Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, Tuple<int, int>> traceMap;
+    private Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, TraceData> traceMap;
     private Dictionary<ISymbolicExpressionTree, List<ISymbolicExpressionTreeNode>> nodeListCache;
 
@@ -42,5 +42,5 @@
     public TraceCalculator() {
       traceGraph = new GenealogyGraph<ISymbolicExpressionTree>();
-      traceMap = new Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, Tuple<int, int>>();
+      traceMap = new Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, TraceData>();
       nodeListCache = new Dictionary<ISymbolicExpressionTree, List<ISymbolicExpressionTreeNode>>();
     }
@@ -63,5 +63,5 @@
       int subtreeIndex, ISymbolicExpressionTreeNode subtree) {
       traceGraph = new GenealogyGraph<ISymbolicExpressionTree>();
-      traceMap = new Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, Tuple<int, int>>();
+      traceMap = new Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, TraceData>();
       return null;
     }
@@ -69,5 +69,5 @@
     public IGenealogyGraph<ISymbolicExpressionTree> Trace(IGenealogyGraphNode<ISymbolicExpressionTree> node, int subtreeIndex) {
       traceGraph = new GenealogyGraph<ISymbolicExpressionTree>();
-      traceMap = new Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, Tuple<int, int>>();
+      traceMap = new Dictionary<IGenealogyGraphNode<ISymbolicExpressionTree>, TraceData>();
       nodeListCache = new Dictionary<ISymbolicExpressionTree, List<ISymbolicExpressionTreeNode>>();
       TraceRecursive(node, subtreeIndex);
@@ -137,5 +137,5 @@
             if (fi < si + sl) {
               // subtree contains fragment => branching point in the fragment graph
-              var n = GetTraceNode(g, si, fi);
+              var n = GetTraceNode(g, si, fi); // current node becomes "last" as we restart tracing from the parent
               TraceRecursive(parent0, si, n);
               TraceRecursive(parent1, fragment.Index2, n);
@@ -157,5 +157,5 @@
           // check if the subtree and the fragment overlap => branch out
           if ((si == fi) || (si < fi && fi < si + sl) || (fi < si && si < fi + fl)) {
-            var n = GetTraceNode(g, si, fi);
+            var n = GetTraceNode(g, si, fi); // current node becomes "last" as we restart tracing from the parent
             int i = si < fi ? si : fi;
             TraceRecursive(parent0, i, n);
@@ -190,5 +190,5 @@
         traceGraph.AddVertex(n);
         Debug.Assert(!traceMap.ContainsKey(n));
-        traceMap[n] = new Tuple<int, int>(si, fi);
+        traceMap[n] = new TraceData(si, fi, -1, -1); // only the first two fields are needed
       }
       return n;
@@ -222,13 +222,24 @@
         return;
       var lastTraceData = traceMap[last];
-      int lastSi = lastTraceData.Item1; // last subtree index (index of the traced subtree in the parent)
-      int lastFi = lastTraceData.Item2; // last fragment index (index of the fragment in the parent)
-      var td = new Tuple<int, int, int, int>(si, fi, lastSi, lastFi); // trace data
-      var arc = n.InArcs.SingleOrDefault(a => a.Source == last && a.Data.Equals(td));
+      int lastSi = lastTraceData.SubtreeIndex; // last subtree index (index of the traced subtree in the previous trace node)
+      int lastFi = lastTraceData.FragmentIndex; // last fragment index (index of the fragment in the previous trace node)
+      var td = new TraceData(si, fi, lastSi, lastFi); // trace data
+      var arc = n.OutArcs.SingleOrDefault(a => a.Target == last && a.Data.Equals(td));
       if (arc == null) {
-        arc = new GenealogyGraphArc(last, n) { Data = td };
+        arc = new GenealogyGraphArc(n, last) { Data = td };
         traceGraph.AddArc(arc);
       }
     }
+  }
+  // this class is here to help clarify the semantics
+  internal class TraceData : Tuple<int, int, int, int> {
+    public TraceData(int currentSubtreeIndex, int currentFragmentIndex, int lastSubtreeIndex, int lastFragmentIndex)
+      : base(currentSubtreeIndex, currentFragmentIndex, lastSubtreeIndex, lastFragmentIndex) {
+    }
+
+    public int SubtreeIndex { get { return Item1; } }
+    public int FragmentIndex { get { return Item2; } }
+    public int LastSubtreeIndex { get { return Item3; } }
+    public int LastFragmentIndex { get { return Item4; } }
   }
 
