- Timestamp:
- 02/05/15 13:55:04 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Collections/DirectedGraph/DirectedGraph.cs
r11444 r11912 102 102 vertex.ArcAdded += Vertex_ArcAdded; 103 103 vertex.ArcRemoved += Vertex_ArcRemoved; 104 OnVerte dAdded(this, new EventArgs<IVertex>(vertex));104 OnVertexAdded(this, new EventArgs<IVertex>(vertex)); 105 105 } 106 106 } 107 107 108 108 public virtual void AddVertices(IEnumerable<IVertex> vertexList) { 109 var hash = new HashSet<IVertex>(vertexList); 110 var arcList = vertexList.SelectMany(v => v.InArcs.Concat(v.OutArcs)); 111 if (arcList.Any(x => !hash.Contains(x.Source) || !hash.Contains(x.Target))) 112 throw new ArgumentException("Vertex arcs are connected to vertices not in the graph."); 113 // if everything is in order, add the vertices to the directed graph 114 foreach (var v in vertexList) 115 vertices.Add(v); 116 foreach (var a in arcList) 117 arcs.Add(a); 109 foreach (var v in vertexList) { AddVertex(v); } 118 110 } 119 111 120 112 public virtual void RemoveVertices(IEnumerable<IVertex> vertexList) { 121 foreach (var v in vertexList) 122 RemoveVertex(v); 113 foreach (var v in vertexList) { RemoveVertex(v); } 123 114 } 124 115 … … 156 147 } 157 148 149 public virtual void AddArcs(IEnumerable<IArc> arcList) { 150 foreach (var a in arcList) { AddArc(a); } 151 } 152 158 153 public virtual void RemoveArc(IArc arc) { 159 154 arcs.Remove(arc); … … 164 159 } 165 160 161 public virtual void RemoveArcs(IEnumerable<IArc> arcList) { 162 foreach (var a in arcList) { RemoveArc(a); } 163 } 164 166 165 protected virtual void Vertex_ArcAdded(object sender, EventArgs<IArc> args) { 167 166 // the ArcAdded event is fired by a vertex when an arc from/to another vertex is added to its list of connections … … 178 177 // events 179 178 public event EventHandler<EventArgs<IVertex>> VertexAdded; 180 protected virtual void OnVerte dAdded(object sender, EventArgs<IVertex> args) {179 protected virtual void OnVertexAdded(object sender, EventArgs<IVertex> args) { 181 180 var added = VertexAdded; 182 181 if (added != null)
Note: See TracChangeset
for help on using the changeset viewer.