Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/31/14 17:11:39 (10 years ago)
Author:
bburlacu
Message:

#1772: Ported the rest of the changes to the DirectedGraph and Vertex to the GenealogyGraph and GenealogyGraphNode. Adapted tracking operators, analyzers and views.

File:
1 edited

Legend:

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

    r11233 r11253  
    6969    public override IArc AddArc(IVertex source, IVertex target) {
    7070      var arc = new GenealogyGraphArc((IGenealogyGraphNode)source, (IGenealogyGraphNode)target);
    71       source.AddArc(arc);
    72       target.AddArc(arc);
    73       arcs.Add(arc);
     71      base.AddArc(arc);
    7472      return arc;
    7573    }
     
    8280      Ranks[node.Rank].Add(node);
    8381
    84       if (contentMap.ContainsKey(node.Content))
     82      if (contentMap.ContainsKey(node.Data))
    8583        throw new InvalidOperationException("Duplicate content is not allowed in the genealogy graph.");
    86       contentMap[node.Content] = node;
     84      contentMap[node.Data] = node;
    8785
    8886      if (idMap.ContainsKey(node.Id))
    8987        throw new InvalidOperationException("Duplicate content is not allowed in the genealogy graph.");
    9088      idMap[node.Id] = node;
    91 
    92       vertex.Changed += OnVertexChanged;
    9389    }
    9490
    9591    public override void RemoveVertex(IVertex vertex) {
    9692      var node = (IGenealogyGraphNode)vertex;
    97       contentMap.Remove(node.Content);
     93      contentMap.Remove(node.Data);
    9894      idMap.Remove(node.Id);
    9995      if (Ranks.ContainsKey(node.Rank)) {
     
    129125      ranks.Clear();
    130126    }
    131 
    132     protected override void OnVertexChanged(object sender, EventArgs args) {
    133       base.OnVertexChanged(sender, args);
    134 
    135       var vertex = (IGenealogyGraphNode)sender;
    136       if (!contentMap.ContainsKey(vertex.Content)) {
    137         // vertex has received new content
    138       }
    139     }
    140127  }
    141128
    142   //  [StorableClass]
    143   //  [Item("GenealogyGraph", "A class representing a genealogy graph")]
    144   //  public class GenealogyGraph<T> : DirectedGraph, IGenealogyGraph<T> where T : class, IItem {
    145   //    // members and properties
    146   //    [Storable]
    147   //    private Dictionary<double, List<IGenealogyGraphNode>> ranks;
    148   //    public Dictionary<double, List<IGenealogyGraphNode>> Ranks {
    149   //      get { return ranks; }
    150   //      set { ranks = value; }
    151   //    }
    152   //    public new IEnumerable<IGenealogyGraphNode<T>> Vertices {
    153   //      get { return from n in base.Vertices select (IGenealogyGraphNode<T>)n; }
    154   //    }
    155   //    // contructors
    156   //    protected GenealogyGraph(GenealogyGraph<T> original, Cloner cloner)
    157   //      : base(original, cloner) {
    158   //    }
    159   //    public override IDeepCloneable Clone(Cloner cloner) {
    160   //      return new GenealogyGraph<T>(this, cloner);
    161   //    }
    162   //
    163   //    [StorableConstructor]
    164   //    protected GenealogyGraph(bool deserializing) : base(deserializing) { }
    165   //    public GenealogyGraph() {
    166   //      Ranks = new Dictionary<double, List<IGenealogyGraphNode>>();
    167   //    }
    168   //
    169   //    // methods
    170   //    public override void AddVertex(IVertex vertex) {
    171   //      base.AddVertex(vertex);
    172   //      var node = (IGenealogyGraphNode)vertex;
    173   //      if (!Ranks.ContainsKey(node.Rank)) {
    174   //        Ranks[node.Rank] = new List<IGenealogyGraphNode>();
    175   //      }
    176   //      Ranks[node.Rank].Add(node);
    177   //    }
    178   //
    179   //    public override void RemoveVertex(IVertex vertex) {
    180   //      var node = (IGenealogyGraphNode<T>)vertex;
    181   //      if (Ranks.ContainsKey(node.Rank)) {
    182   //        Ranks[node.Rank].Remove(node);
    183   //      }
    184   //      base.RemoveVertex(vertex);
    185   //    }
    186   //
    187   //    public override IArc AddArc(IVertex source, IVertex target) {
    188   //      var arc = new GenealogyGraphArc((IGenealogyGraphNode)source, (IGenealogyGraphNode)target);
    189   //      source.AddArc(arc);
    190   //      target.AddArc(arc);
    191   //      arcs.Add(arc);
    192   //      return arc;
    193   //    }
    194   //
    195   //    IEnumerable<IGenealogyGraphNode> IGenealogyGraph.Vertices {
    196   //      get { return Vertices; }
    197   //    }
    198   //
    199   //    public IGenealogyGraphNode GetByContent(object content)
    200   //    {
    201   //      IGenealogyGraphNode result;
    202   //      contentMap.
    203   //    }
    204   //
    205   //    public event EventHandler GraphUpdated;
    206   //    private void OnGraphUpdated(object sender, EventArgs args) {
    207   //      var updated = GraphUpdated;
    208   //      if (updated != null) updated(sender, args);
    209   //    }
    210   //  }
     129  [Item("GenealogyGraph", "A specialization of the genealogy graph with T as content for vertices")]
    211130  [StorableClass]
    212 
    213   [Item("GenealogyGraph", "A specialization of the genealogy graph with T as content for vertices")]
    214131  public class GenealogyGraph<T> : GenealogyGraph, IGenealogyGraph<T> where T : class, IItem {
    215132    public new IEnumerable<IGenealogyGraphNode<T>> Vertices {
Note: See TracChangeset for help on using the changeset viewer.