Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11383


Ignore:
Timestamp:
09/23/14 14:11:37 (10 years ago)
Author:
bburlacu
Message:

#1772: BeforeManipulatorOperator: preserve fragment data after vertex cloning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs

    r11288 r11383  
    5353    public override IOperation Apply() {
    5454      // since mutation always takes place after crossover, the vertex for the current child is already in the tree
    55       var v = (IGenealogyGraphNode<T>)GenealogyGraph.GetByContent(ChildParameter.ActualValue);
    56       var c = (IGenealogyGraphNode<T>)v.Clone();
    57       c.Rank = v.Rank - 0.5;
    58       GenealogyGraph.AddVertex(c);
     55      var childVertex = (IGenealogyGraphNode<T>)GenealogyGraph.GetByContent(ChildParameter.ActualValue);
     56      var clonedVertex = (IGenealogyGraphNode<T>)childVertex.Clone();
     57      clonedVertex.Rank = childVertex.Rank - 0.5;
     58      GenealogyGraph.AddVertex(clonedVertex);
    5959
    60       var arcs = v.InArcs.ToList();
     60      var arcs = childVertex.InArcs.ToList();
    6161      foreach (var arc in arcs) {
    6262        var p = arc.Source;
    6363        GenealogyGraph.RemoveArc(arc);
    64         GenealogyGraph.AddArc(new GenealogyGraphArc(p, c));
     64        GenealogyGraph.AddArc(new GenealogyGraphArc(p, clonedVertex));
    6565      }
    66 
    67       GenealogyGraph.AddArc(c, v);
     66      clonedVertex.InArcs.Last().Data = arcs.Last().Data; // preserve fragment data
     67      GenealogyGraph.AddArc(new GenealogyGraphArc(clonedVertex, childVertex));
    6868
    6969      return base.Apply();
Note: See TracChangeset for help on using the changeset viewer.