Changeset 9419 for branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking/3.4/GenericGraph/Vertex.cs
- Timestamp:
- 05/02/13 13:18:57 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking/3.4/GenericGraph
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking/3.4/GenericGraph/Vertex.cs
r9247 r9419 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 27 26 28 namespace HeuristicLab.EvolutionaryTracking { 27 29 [StorableClass] 28 public class Vertex : IVertex { 29 public string Id { get; private set; } 30 public string Label { get; set; } 31 public double Weight { get; set; } 32 public List<Arc> InEdges { get; private set; } 33 public List<Arc> OutEdges { get; private set; } 34 private object content; 30 public class Vertex : Item, IVertex 31 { 32 [Storable] 33 private string id; 34 public string Id { get { return id; } } 35 [Storable] private string label; 36 public string Label { get { return label; } set { label = value; } } 37 [Storable] private double weight; 38 public double Weight { get { return weight; } set { weight = value; } } 39 [Storable] private List<IEdge> inEdges; 40 public List<IEdge> InEdges { get { return inEdges; } private set { inEdges = value; } } 41 [Storable] private List<IEdge> outEdges; 42 public List<IEdge> OutEdges { get { return outEdges; }private set { outEdges = value; }} 43 [Storable] private object content; 35 44 public object Content { 36 45 get { return content; } … … 43 52 44 53 [StorableConstructor] 45 public Vertex(bool deserializing) { }54 public Vertex(bool deserializing) : base(deserializing) { } 46 55 47 56 public Vertex() { 48 Id = Guid.NewGuid().ToString(); 57 id = Guid.NewGuid().ToString(); 58 } 59 60 [StorableHook(HookType.AfterDeserialization)] 61 private void AfterDeserialization() 62 { 63 if (id == null) { 64 id = Guid.NewGuid().ToString(); 65 } 66 } 67 68 protected Vertex(Vertex original, Cloner cloner) 69 : base(original, cloner) { 70 Content = original.Content; 71 id = Guid.NewGuid().ToString(); 72 Label = original.Label; 73 Content = original.Content; 74 InEdges = new List<IEdge>(original.InEdges); 75 OutEdges = new List<IEdge>(original.OutEdges); 76 } 77 78 public override IDeepCloneable Clone(Cloner cloner) { 79 return new Vertex(this, cloner); 49 80 } 50 81 51 82 public Vertex(Vertex node) { 52 Id = Guid.NewGuid().ToString();83 id = Guid.NewGuid().ToString(); 53 84 Label = node.Label; 54 85 Content = node.Content; 55 InEdges = new List< Arc>(node.InEdges);56 OutEdges = new List< Arc>(node.OutEdges);86 InEdges = new List<IEdge>(node.InEdges); 87 OutEdges = new List<IEdge>(node.OutEdges); 57 88 } 58 89 … … 108 139 public void AddForwardArc(IVertex target, double weight = 0.0, object data = null) { 109 140 var e = new Arc { Source = this, Target = target, Data = data, Weight = weight }; 110 if (OutEdges == null) OutEdges = new List< Arc> { e };141 if (OutEdges == null) OutEdges = new List<IEdge> { e }; 111 142 else OutEdges.Add(e); 112 143 } 113 public void AddForwardArc( Arcarc) {144 public void AddForwardArc(IEdge arc) { 114 145 if (arc.Source == null) { arc.Source = this; } 115 146 if (arc.Source != this) { throw new Exception("AddForwardArc: Source should be equal to this."); } 116 if (OutEdges == null) { OutEdges = new List< Arc> { arc }; } else { OutEdges.Add(arc); }147 if (OutEdges == null) { OutEdges = new List<IEdge> { arc }; } else { OutEdges.Add(arc); } 117 148 } 118 public void AddReverseArc( Arcarc) {149 public void AddReverseArc(IEdge arc) { 119 150 if (arc.Target == null) { arc.Target = this; } 120 151 if (arc.Target != this) { throw new Exception("AddReverseArc: Target should be equal to this."); }; 121 if (InEdges == null) { InEdges = new List< Arc> { arc }; } else { InEdges.Add(arc); }152 if (InEdges == null) { InEdges = new List<IEdge> { arc }; } else { InEdges.Add(arc); } 122 153 } 123 154 public void AddReverseArc(IVertex source, double weight = 0.0, object data = null) { 124 155 var e = new Arc { Source = source, Target = this, Data = data, Weight = weight }; 125 if (InEdges == null) InEdges = new List< Arc> { e };156 if (InEdges == null) InEdges = new List<IEdge> { e }; 126 157 else InEdges.Add(e); 127 158 }
Note: See TracChangeset
for help on using the changeset viewer.