Changeset 11253 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
- Timestamp:
- 07/31/14 17:11:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraph.cs
r11233 r11253 69 69 public override IArc AddArc(IVertex source, IVertex target) { 70 70 var arc = new GenealogyGraphArc((IGenealogyGraphNode)source, (IGenealogyGraphNode)target); 71 source.AddArc(arc); 72 target.AddArc(arc); 73 arcs.Add(arc); 71 base.AddArc(arc); 74 72 return arc; 75 73 } … … 82 80 Ranks[node.Rank].Add(node); 83 81 84 if (contentMap.ContainsKey(node. Content))82 if (contentMap.ContainsKey(node.Data)) 85 83 throw new InvalidOperationException("Duplicate content is not allowed in the genealogy graph."); 86 contentMap[node. Content] = node;84 contentMap[node.Data] = node; 87 85 88 86 if (idMap.ContainsKey(node.Id)) 89 87 throw new InvalidOperationException("Duplicate content is not allowed in the genealogy graph."); 90 88 idMap[node.Id] = node; 91 92 vertex.Changed += OnVertexChanged;93 89 } 94 90 95 91 public override void RemoveVertex(IVertex vertex) { 96 92 var node = (IGenealogyGraphNode)vertex; 97 contentMap.Remove(node. Content);93 contentMap.Remove(node.Data); 98 94 idMap.Remove(node.Id); 99 95 if (Ranks.ContainsKey(node.Rank)) { … … 129 125 ranks.Clear(); 130 126 } 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 content138 }139 }140 127 } 141 128 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")] 211 130 [StorableClass] 212 213 [Item("GenealogyGraph", "A specialization of the genealogy graph with T as content for vertices")]214 131 public class GenealogyGraph<T> : GenealogyGraph, IGenealogyGraph<T> where T : class, IItem { 215 132 public new IEnumerable<IGenealogyGraphNode<T>> Vertices {
Note: See TracChangeset
for help on using the changeset viewer.