[10267] | 1 |
|
---|
| 2 | using System;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using HeuristicLab.Common;
|
---|
| 5 | using HeuristicLab.Core;
|
---|
| 6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 7 |
|
---|
| 8 | namespace 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 | }
|
---|