Changeset 10888 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
- Timestamp:
- 05/26/14 01:56:35 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
r10886 r10888 29 29 namespace HeuristicLab.EvolutionTracking { 30 30 [StorableClass] 31 [Item("GenealogyGraph", " ")]31 [Item("GenealogyGraph", "A class representing a genealogy graph")] 32 32 public class GenealogyGraph : DirectedGraph, IGenealogyGraph { 33 33 [Storable] … … 41 41 } 42 42 43 public IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target) {44 var arc = new GenealogyGraphArc(source, target);45 source.AddForwardArc(arc);46 target.AddReverseArc(arc);47 return arc;48 }49 50 43 protected GenealogyGraph(GenealogyGraph original, Cloner cloner) 51 44 : base(original, cloner) { 45 Ranks = new Dictionary<double, List<IGenealogyGraphNode>>(original.Ranks); 52 46 } 53 47 public override IDeepCloneable Clone(Cloner cloner) { … … 59 53 Ranks = new Dictionary<double, List<IGenealogyGraphNode>>(); 60 54 } 55 56 public override IArc AddArc(IVertex source, IVertex target) { 57 var arc = new GenealogyGraphArc((IGenealogyGraphNode)source, (IGenealogyGraphNode)target); 58 source.AddForwardArc(arc); 59 target.AddReverseArc(arc); 60 return arc; 61 } 62 61 63 public override void AddVertex(IVertex vertex) { 64 base.AddVertex(vertex); 62 65 var node = (IGenealogyGraphNode)vertex; 63 66 if (!Ranks.ContainsKey(node.Rank)) 64 67 Ranks[node.Rank] = new List<IGenealogyGraphNode>(); 65 68 Ranks[node.Rank].Add(node); 66 base.AddVertex(vertex);67 69 } 68 70 public override void RemoveVertex(IVertex vertex) { … … 94 96 95 97 [StorableClass] 96 [Item("GenealogyGraph", " ")]98 [Item("GenealogyGraph", "A class representing a genealogy graph")] 97 99 public class GenealogyGraph<T> : DirectedGraph, IGenealogyGraph<T> where T : class, IItem { 98 100 // members and properties … … 106 108 get { return from n in base.Nodes select (IGenealogyGraphNode<T>)n; } 107 109 } 108 109 public IGenealogyGraphArc AddArc(IGenealogyGraphNode source, IGenealogyGraphNode target) {110 var arc = new GenealogyGraphArc(source, target);111 source.AddForwardArc(arc);112 target.AddReverseArc(arc);113 return arc;114 }115 116 110 // contructors 117 111 protected GenealogyGraph(GenealogyGraph<T> original, Cloner cloner) … … 128 122 // methods 129 123 public override void AddVertex(IVertex vertex) { 124 base.AddVertex(vertex); 130 125 var node = (IGenealogyGraphNode<T>)vertex; 131 126 if (!Ranks.ContainsKey(node.Rank)) { … … 133 128 } 134 129 Ranks[node.Rank].Add(node); 135 base.AddVertex(vertex);136 130 } 137 131 public override void RemoveVertex(IVertex vertex) { … … 142 136 base.RemoveVertex(vertex); 143 137 } 144 138 public override IArc AddArc(IVertex source, IVertex target) { 139 var arc = new GenealogyGraphArc((IGenealogyGraphNode)source, (IGenealogyGraphNode)target); 140 source.AddForwardArc(arc); 141 target.AddReverseArc(arc); 142 return arc; 143 } 145 144 IEnumerable<IGenealogyGraphNode> IGenealogyGraph.Nodes { 146 145 get { return Nodes; } 147 146 } 148 149 147 public event EventHandler GraphUpdated; 150 148 private void OnGraphUpdated(object sender, EventArgs args) {
Note: See TracChangeset
for help on using the changeset viewer.