Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11969 for branches


Ignore:
Timestamp:
02/07/15 02:52:06 (10 years ago)
Author:
bburlacu
Message:

#1772: Restore correct order of arcs when cloning or deserializing a GenealogyGraph (due to changes in the trunk in the Directed graph, previous code was not working anymore).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs

    r11925 r11969  
    3838
    3939    private readonly Comparison<IArc<IDeepCloneable>> compareArcs = (a, b) => {
    40       if (a.Data == b.Data)
     40      var da = a.Data;
     41      var db = b.Data;
     42
     43      if ((da == null && db == null) || (da != null && db != null))
    4144        return 0;
    42       if (a.Data == null)
     45
     46      if (da == null)
    4347        return -1;
     48
    4449      return 1;
    4550    };
     
    5560      : base(original, cloner) {
    5661      RebuildDictionaries();
    57 
    58       foreach (var arcs in Vertices.Select(v => v.InArcs.ToList())) { arcs.Sort(compareArcs); }
     62      // sort arcs so that in the case of crossover (child vertex with two parents)
     63      // the arc which holds the fragment information is always last
     64      foreach (var arcList in base.Vertices.Select(v => (List<IArc>)v.InArcs)) {
     65        arcList.Sort((a, b) => compareArcs((IGenealogyGraphArc)a, (IGenealogyGraphArc)b));
     66      }
    5967    }
    6068    public override IDeepCloneable Clone(Cloner cloner) {
     
    6977    private void AfterDeserialization() {
    7078      RebuildDictionaries();
    71       foreach (var arcs in Vertices.Select(v => v.InArcs.ToList())) { arcs.Sort(compareArcs); }
     79      foreach (var arcList in base.Vertices.Select(v => (List<IArc>)v.InArcs)) {
     80        arcList.Sort((a, b) => compareArcs((IGenealogyGraphArc)a, (IGenealogyGraphArc)b));
     81      }
    7282    }
    7383    public GenealogyGraph() {
Note: See TracChangeset for help on using the changeset viewer.