Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11750


Ignore:
Timestamp:
01/13/15 17:12:00 (9 years ago)
Author:
bburlacu
Message:

#1772: Changed Ancestors and Descendants methods to not include the current graph node as it better fits the definition of what an ancestor (or descendant) is.

File:
1 edited

Legend:

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

    r11459 r11750  
    5959    }
    6060
     61    public IEnumerable<IGenealogyGraphNode> Parents {
     62      get { return InArcs.Select(a => a.Source); }
     63    }
     64    public IEnumerable<IGenealogyGraphNode> Children {
     65      get { return OutArcs.Select(a => a.Target); }
     66    }
     67
    6168    public IEnumerable<IGenealogyGraphNode> Ancestors {
    6269      get {
     70        if (!Parents.Any())
     71          return Enumerable.Empty<IGenealogyGraphNode>();
    6372        // for performance, we use a hashset for lookup and a list for iteration
    64         var nodes = new HashSet<IGenealogyGraphNode> { this };
    65         var list = new List<IGenealogyGraphNode> { this };
     73        var nodes = new HashSet<IGenealogyGraphNode>(Parents);
     74        var list = new List<IGenealogyGraphNode>(Parents);
    6675        int i = 0;
    6776        while (i != list.Count) {
     
    7685      }
    7786    }
    78     /// <summary>
    79     /// Performs a downward-breath-traversal of the genealogy graph using the nodes OutArcs
    80     /// </summary>
    81     /// <returns>All the descendants of the current node</returns>
     87
    8288    public IEnumerable<IGenealogyGraphNode> Descendants {
    8389      get {
    84         var nodes = new HashSet<IGenealogyGraphNode> { this };
    85         var list = new List<IGenealogyGraphNode> { this };
     90        var nodes = new HashSet<IGenealogyGraphNode>(Children);
     91        var list = new List<IGenealogyGraphNode>(Children);
    8692        int i = 0;
    8793        while (i != list.Count) {
     
    96102      }
    97103    }
     104
    98105    [Storable]
    99106    public string Id { get; private set; }
     
    119126    public int CompareTo(IGenealogyGraphNode other) {
    120127      return Quality.CompareTo(other.Quality);
    121     }
    122     public IEnumerable<IGenealogyGraphNode> Parents {
    123       get { return InArcs.Select(a => a.Source); }
    124     }
    125     public IEnumerable<IGenealogyGraphNode> Children {
    126       get { return OutArcs.Select(a => a.Target); }
    127128    }
    128129  }
Note: See TracChangeset for help on using the changeset viewer.