Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/22/14 13:49:35 (10 years ago)
Author:
bburlacu
Message:

#1772: Simplified GenealogyGraph (and related components) API in an effort to improve speed and memory consumption (eg., by sharing the same arc when walking the graph in both directions: parent-child and child-parent).

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph
Files:
4 edited

Legend:

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

    r10833 r10886  
    4040      get { return from n in base.Nodes select (IGenealogyGraphNode)n; }
    4141    }
     42
     43    public IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target) {
     44      var arc = new GenealogyGraphArc(source, target);
     45      source.AddForwardArc(arc);
     46      target.AddReverseArc(arc);
     47      return arc;
     48    }
     49
    4250    protected GenealogyGraph(GenealogyGraph original, Cloner cloner)
    4351      : base(original, cloner) {
     
    98106      get { return from n in base.Nodes select (IGenealogyGraphNode<T>)n; }
    99107    }
     108
     109    public IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target) {
     110      var arc = new GenealogyGraphArc(source, target);
     111      source.AddForwardArc(arc);
     112      target.AddReverseArc(arc);
     113      return arc;
     114    }
     115
    100116    // contructors
    101117    protected GenealogyGraph(GenealogyGraph<T> original, Cloner cloner)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphArc.cs

    r10293 r10886  
    3232    protected GenealogyGraphArc(GenealogyGraphArc original, Cloner cloner)
    3333      : base(original, cloner) {
     34      this.Target = original.Target;
     35      this.Source = original.Source;
     36      this.Label = original.Label;
     37      this.Weight = original.Weight;
     38      this.Data = original.Data;
    3439    }
    3540
    36     public GenealogyGraphArc() { }
     41    protected GenealogyGraphArc() { }
     42
     43    public GenealogyGraphArc(IGenealogyGraphNode source, IGenealogyGraphNode target, object data = null) {
     44      Source = source;
     45      Target = target;
     46      Data = data;
     47    }
    3748
    3849    public override IDeepCloneable Clone(Cloner cloner) {
     
    6071      Data = (T)original.Data.Clone();
    6172    }
    62     public GenealogyGraphArc() { }
    6373
    6474    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs

    r10685 r10886  
    107107      return Quality.CompareTo(other.Quality);
    108108    }
    109     public new void AddForwardArc(IVertex target, double w = 0.0, object data = null) {
    110       var arc = new GenealogyGraphArc { Source = this, Target = (IGenealogyGraphNode)target, Data = data, Weight = w };
    111       base.AddForwardArc(arc);
    112     }
    113     public new void AddReverseArc(IVertex source, double w = 0.0, object data = null) {
    114       var arc = new GenealogyGraphArc { Source = (IGenealogyGraphNode)source, Target = this, Data = data, Weight = w };
    115       base.AddReverseArc(arc);
    116     }
    117109    public IEnumerable<IGenealogyGraphNode> Parents {
    118110      get { return InArcs.Select(a => a.Source); }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/Interfaces/IGenealogyGraph.cs

    r10830 r10886  
    2727    Dictionary<double, List<IGenealogyGraphNode>> Ranks { get; }
    2828    new IEnumerable<IGenealogyGraphNode> Nodes { get; }
     29    IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target);
    2930  }
    3031
Note: See TracChangeset for help on using the changeset viewer.