Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/10/12 17:17:14 (12 years ago)
Author:
bburlacu
Message:

#1772: Changelog:

  • Removed GetCutIndex method, and corresponding index field in the GenealogyGraphNode.
  • Implemented tracking for mutated fragments.
  • Improved FindMatch method.
  • Added IterateNodesBreadth functionality to symbolic expression trees and nodes.
  • Added check conditions for clearing global tracking structures so that the 2 analyzers are not mutually exclusive anymore.
File:
1 edited

Legend:

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

    r7785 r7792  
    9595    /// <param name="rank">The node rank</param>
    9696    /// <param name="elite">Specifies if this node is an elite</param>
    97     public void AddNode(T t, double quality = 0.0, string label = "", double rank = 0, bool elite = false, int cutIndex = -1) {
     97    public void AddNode(T t, double quality = 0.0, string label = "", double rank = 0, bool elite = false) {
    9898      if (HasNode(t)) return;
    99       _dictionary[t] = new GenealogyGraphNode { Data = t, Quality = quality, Label = label, IsElite = elite, Rank = rank, CutpointIndex = cutIndex };
     99      _dictionary[t] = new GenealogyGraphNode { Data = t, Quality = quality, Label = label, IsElite = elite, Rank = rank };
    100100    }
    101101
     
    103103    ///  more of a low level method to minimize memory usage when creating and returning subgraphs
    104104    /// </summary>
    105     /// <param name="n">The node to be added</param>
    106     public void AddNode(GenealogyGraphNode n) {
    107       var t = (T)n.Data;
     105    /// <param name="node">The node to be added</param>
     106    public void AddNode(GenealogyGraphNode node) {
     107      var t = (T)node.Data;
    108108      if (HasNode(t)) return;
    109       _dictionary[t] = n;
     109      _dictionary[t] = node;
    110110    }
    111111
     
    116116    public void RemoveNode(T t) {
    117117      if (!_dictionary.ContainsKey(t)) return;
    118       GenealogyGraphNode n = _dictionary[t];
    119       if (n.InEdges != null) {
    120         foreach (var e in n.InEdges.Where(e => e.Target.OutEdges != null)) {
    121           e.Target.OutEdges.RemoveAll(arc => arc.Target == n);
     118      var node = _dictionary[t];
     119      if (node.InEdges != null) {
     120        foreach (var e in node.InEdges.Where(e => e.Target.OutEdges != null)) {
     121          e.Target.OutEdges.RemoveAll(arc => arc.Target == node);
    122122          if (!e.Target.OutEdges.Any())
    123123            e.Target.OutEdges = null; // set to null to be a little more memory efficient
    124124        }
    125         n.InEdges = null;
    126       }
    127       if (n.OutEdges != null) {
    128         foreach (var e in n.OutEdges.Where(e => e.Target.InEdges != null)) {
    129           e.Target.InEdges.RemoveAll(arc => arc.Target == n);
     125        node.InEdges = null;
     126      }
     127      if (node.OutEdges != null) {
     128        foreach (var e in node.OutEdges.Where(e => e.Target.InEdges != null)) {
     129          e.Target.InEdges.RemoveAll(arc => arc.Target == node);
    130130          if (!e.Target.InEdges.Any())
    131131            e.Target.InEdges = null; // set to null to be a little more memory efficient
    132132        }
    133         n.OutEdges = null;
     133        node.OutEdges = null;
    134134      }
    135135      _dictionary.Remove(t);
     
    145145    /// <param name="a"></param>
    146146    /// <param name="b"></param>
    147     /// <param name="label"></param>
    148     public void AddArc(T a, T b, int opType = 0) {
     147    public void AddArc(T a, T b) {
    149148      GenealogyGraphNode src, dest;
    150149      if (!HasNode(a)) {
     
    161160      }
    162161      // add forward and reverse arcs
    163       src.AddForwardArc(dest, opType);
    164       dest.AddReverseArc(src, opType);
    165     }
    166 
    167     public void AddArcs(T[] a, T b, int opType = 0) {
     162      src.AddForwardArc(dest);
     163      dest.AddReverseArc(src);
     164    }
     165
     166    public void AddArcs(T[] a, T b) {
    168167      GenealogyGraphNode src, dest;
    169168      if (!HasNode(b)) {
     
    180179          src = _dictionary[o];
    181180        }
    182         src.AddForwardArc(dest, opType);
    183         dest.AddReverseArc(src, opType);
     181        src.AddForwardArc(dest);
     182        dest.AddReverseArc(src);
    184183      }
    185184    }
     
    193192    public double Quality { get; set; }
    194193    public double Rank { get; set; }
    195     public int CutpointIndex { get; set; }
    196194    public List<GenealogyGraphArc> InEdges { get; set; }
    197195    public List<GenealogyGraphArc> OutEdges { get; set; }
     
    210208      InEdges = node.InEdges;
    211209      OutEdges = node.OutEdges;
    212       CutpointIndex = node.CutpointIndex;
    213     }
    214 
    215     /// <summary>
    216     /// Returns all the ancestors of the current node
    217     /// </summary>
    218     /// <returns></returns>
     210    }
     211
     212    /// <summary>
     213    /// Performs an upward-breath-traversal of the genealogy graph using the nodes InEdges
     214    /// </summary>
     215    /// <returns>All the ancestors of the current node</returns>
    219216    public IEnumerable<GenealogyGraphNode> Ancestors() {
    220217      var nodes = new HashSet<GenealogyGraphNode> { this };
     
    236233
    237234    /// <summary>
    238     /// Returns all the descendants of the current node (identical to above method except for using the OutEdges)
    239     /// </summary>
    240     /// <returns></returns>
     235    /// Performs a downward-breath-traversal of the genealogy graph using the nodes OutEdges
     236    /// </summary>
     237    /// <returns>All the descendants of the current node</returns>
    241238    public IEnumerable<GenealogyGraphNode> Descendants() {
    242239      var nodes = new HashSet<GenealogyGraphNode> { this };
     
    257254    }
    258255
    259     public void AddForwardArc(GenealogyGraphNode target, int opType) {
    260       var e = new GenealogyGraphArc { Target = target, OperatorType = opType };
     256    public void AddForwardArc(GenealogyGraphNode target) {
     257      var e = new GenealogyGraphArc { Target = target };
    261258      if (OutEdges == null) OutEdges = new List<GenealogyGraphArc> { e };
    262259      else OutEdges.Add(e);
    263260    }
    264261
    265     public void AddReverseArc(GenealogyGraphNode target, int opType) {
    266       var e = new GenealogyGraphArc { Target = target, OperatorType = opType };
     262    public void AddReverseArc(GenealogyGraphNode target) {
     263      var e = new GenealogyGraphArc { Target = target };
    267264      if (InEdges == null) InEdges = new List<GenealogyGraphArc> { e };
    268265      else InEdges.Add(e);
     
    289286  public class GenealogyGraphArc {
    290287    public GenealogyGraphNode Target { get; set; }
    291     // OperationType is an identifier for the genetic operation (mutation, crossover) that a graph arc will represent
    292     // So basically it describes which operator was applied to an individual/graph node (the one emitting the arc),
    293     // while Target represents the end result of that operator (node ==GeneticOperation==> Target)
    294     public int OperatorType { get; set; }
    295288    // these two fields are not used, but they might be useful later
    296289    public string Label { get; set; } // might be useful later
Note: See TracChangeset for help on using the changeset viewer.