Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8234


Ignore:
Timestamp:
07/05/12 15:21:07 (12 years ago)
Author:
ascheibe
Message:

#1886 updated graph from evolutionary tracking branch

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/Analyzers/BestIndividualQualityAnalyzer.cs

    r8230 r8234  
    119119        stringMatrix[i, 1] = element.Value;
    120120      }
    121       stringMatrix.ColumnNames = new[] { "Schema", "Occurence in hierarchy" };
     121      stringMatrix.ColumnNames = new[] { "Schema", "Occurences in hierarchy" };
    122122
    123123      Results.Add(new Result(SchemaQualityMatrixParameterName, stringMatrix));
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior/3.3/GenealogyGraph.cs

    r8161 r8234  
    5454    }
    5555
    56     private GenealogyGraph(GenealogyGraph<T> original, Cloner cloner)
     56    protected GenealogyGraph(GenealogyGraph<T> original, Cloner cloner)
    5757      : base(original, cloner) {
    5858      _nodes = new Dictionary<T, GenealogyGraphNode>(original._nodes);
     
    207207    /// <returns>All the ancestors of the current node</returns>
    208208    public IEnumerable<GenealogyGraphNode> Ancestors() {
     209      // for performance, we use a hashset for lookup and a list for iteration
    209210      var nodes = new HashSet<GenealogyGraphNode> { this };
     211      var list = new List<GenealogyGraphNode> { this };
    210212      int i = 0;
    211       while (i != nodes.Count) {
    212         if (nodes.ElementAt(i).InEdges != null) {
    213           foreach (var p in nodes.ElementAt(i).InEdges.Select(e => e.Target)) {
    214             nodes.Add(p);
    215             yield return p;
     213      while (i != list.Count) {
     214        if (list[i].InEdges != null) {
     215          foreach (var e in list[i].InEdges) {
     216            if (nodes.Contains(e.Target)) continue;
     217            nodes.Add(e.Target);
     218            list.Add(e.Target);
    216219          }
    217220        }
    218221        ++i;
    219222      }
     223      return list;
    220224    }
    221225
     
    226230    public IEnumerable<GenealogyGraphNode> Descendants() {
    227231      var nodes = new HashSet<GenealogyGraphNode> { this };
     232      var list = new List<GenealogyGraphNode> { this };
    228233      int i = 0;
    229       while (i != nodes.Count) {
    230         if (nodes.ElementAt(i).OutEdges != null) {
    231           foreach (var p in nodes.ElementAt(i).OutEdges.Select(e => e.Target)) {
    232             nodes.Add(p);
    233             yield return p;
     234      while (i != list.Count) {
     235        if (list[i].OutEdges != null) {
     236          foreach (var e in list[i].OutEdges) {
     237            if (nodes.Contains(e.Target)) continue;
     238            nodes.Add(e.Target);
     239            list.Add(e.Target);
    234240          }
    235241        }
    236242        ++i;
    237243      }
     244      return list;
    238245    }
    239246
Note: See TracChangeset for help on using the changeset viewer.