Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs @ 10267

Last change on this file since 10267 was 10267, checked in by bburlacu, 10 years ago

#1772: Updated files in the HeuristicLab.EvolutionTracking project.

File size: 1.6 KB
Line 
1
2using System;
3using System.Collections.Generic;
4using HeuristicLab.Common;
5using HeuristicLab.Core;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.EvolutionaryTracking {
9  [StorableClass]
10  [Item("GenealogyGraph", "A class representing a genealogy graph")]
11  public class GenealogyGraph : GenealogyGraph<IGenealogyGraphNode> {
12  }
13
14  [StorableClass]
15  [Item("GenealogyGraph", "A class representing a genealogy graph (of a population of individuals) without storing any content for vertices")]
16  public class GenealogyGraph<TVertex> : DirectedGraph<TVertex>, IGenealogyGraph<TVertex> where TVertex : class,IGenealogyGraphNode {
17    [Storable]
18    private Dictionary<double, LinkedList<TVertex>> ranks; // use a linked list for fast insertion/removal
19
20    public Dictionary<double, LinkedList<TVertex>> Ranks {
21      get { return ranks; }
22      set { ranks = value; }
23    }
24
25    public override IDeepCloneable Clone(Cloner cloner) {
26      return new GenealogyGraph<TVertex>(this, cloner);
27    }
28    protected GenealogyGraph(GenealogyGraph<TVertex> original, Cloner cloner)
29      : base(original, cloner) {
30    }
31    [StorableConstructor]
32    protected GenealogyGraph(bool deserializing) : base(deserializing) { }
33
34    public GenealogyGraph() {
35      Ranks = new Dictionary<double, LinkedList<TVertex>>();
36    }
37
38    public event EventHandler GraphUpdated;
39    private void OnGraphUpdated(object sender, EventArgs args) {
40      var updated = GraphUpdated;
41      if (updated != null) updated(sender, args);
42    }
43  }
44}
Note: See TracBrowser for help on using the repository browser.