/// <summary> /// clears all lists. /// </summary> public void Clear() { VertexList.Clear(); EdgeList.Clear(); FaceList.Clear(); EdgeCurveList.Clear(); }
public virtual bool RemoveVertex(TVertex v) { GraphContracts.AssumeNotNull(v, "v"); if (!this.ContainsVertex(v)) { return(false); } // remove outedges { EdgeList edges = this.vertexEdges[v]; if (this.EdgeRemoved != null) // lazily notify { foreach (TEdge edge in edges) { this.OnEdgeRemoved(new EdgeEventArgs <TVertex, TEdge>(edge)); } } this.edgeCount -= edges.Count; edges.Clear(); } // iterage over edges and remove each edge touching the vertex EdgeList edgeToRemove = new EdgeList(); foreach (KeyValuePair <TVertex, EdgeList> kv in this.vertexEdges) { if (kv.Key.Equals(v)) { continue; // we've already } // collect edge to remove foreach (TEdge edge in kv.Value) { if (edge.Target.Equals(v)) { edgeToRemove.Add(edge); } } // remove edges foreach (TEdge edge in edgeToRemove) { kv.Value.Remove(edge); this.OnEdgeRemoved(new EdgeEventArgs <TVertex, TEdge>(edge)); } // update count this.edgeCount -= edgeToRemove.Count; edgeToRemove.Clear(); } System.Diagnostics.Debug.Assert(this.edgeCount >= 0); this.vertexEdges.Remove(v); this.OnVertexRemoved(new VertexEventArgs <TVertex>(v)); return(true); }
public virtual bool RemoveVertex(TVertex v) { if (!this.ContainsVertex(v)) { return(false); } // remove outedges { var edges = this.vertexEdges[v]; if (this.EdgeRemoved != null) // lazily notify { foreach (var edge in edges) { this.OnEdgeRemoved(edge); } } this.edgeCount -= edges.Count; edges.Clear(); } // iterage over edges and remove each edge touching the vertex var edgeToRemove = new EdgeList <TVertex, TEdge>(); foreach (var kv in this.vertexEdges) { if (kv.Key.Equals(v)) { continue; // we've already } // collect edge to remove foreach (var edge in kv.Value) { if (edge.Target.Equals(v)) { edgeToRemove.Add(edge); } } // remove edges foreach (var edge in edgeToRemove) { kv.Value.Remove(edge); this.OnEdgeRemoved(edge); } // update count this.edgeCount -= edgeToRemove.Count; edgeToRemove.Clear(); } Contract.Assert(this.edgeCount >= 0); this.vertexEdges.Remove(v); this.OnVertexRemoved(v); return(true); }
} // private void ComputeLabelsFromDepths() /// <summary> /// If edges which have undergone dimensional collapse are found, /// replace them with a new edge which is a L edge /// </summary> private void ReplaceCollapsedEdges() { ArrayList newEdges = new ArrayList(_edgeList); foreach (object obj in _edgeList) { Edge e = (Edge)obj; if (e.IsCollapsed()) { newEdges.Remove(obj); newEdges.Add(e.GetCollapsedEdge()); } } _edgeList.Clear(); // remove all elements and then add back in. _edgeList.AddRange(newEdges); } // private void ReplaceCollapsedEdges()
public void ClearInEdges(TVertex v) { GraphContracts.AssumeInVertexSet(this, v, "v"); EdgeList inEdges = this.vertexInEdges[v]; foreach (TEdge edge in inEdges) { this.vertexOutEdges[edge.Source].Remove(edge); this.OnEdgeRemoved(new EdgeEventArgs <TVertex, TEdge>(edge)); } this.edgeCount -= inEdges.Count; inEdges.Clear(); GraphContracts.Assert(this.edgeCount >= 0); }
public void ClearOutEdges(TVertex v) { GraphContracts.AssumeInVertexSet(this, v, "v"); EdgeList edges = this.vertexEdges[v]; int count = edges.Count; if (this.EdgeRemoved != null) // call only if someone is listening { foreach (TEdge edge in edges) { this.OnEdgeRemoved(new EdgeEventArgs <TVertex, TEdge>(edge)); } } edges.Clear(); this.edgeCount -= count; GraphContracts.Assert(this.edgeCount >= 0); }
public void RemoveNodeByID(int id) { for (int i = 0; i < nodeTable.Count; ++i) { if (nodeTable[i].id == id) { nodeTable.Remove(id); EdgeList edgeList = edgeListTable[id]; for (int j = 0; j < edgeList.Count; ++j) { GraphEdge edge = edgeList[j]; RemoveEdge(edge.to, edge.from); } edgeList.Clear(); edgeListTable.Remove(id); break; } } }
public void Fracture(Environment container, List <Environment> obstacles) { var fracturedPath = Utility.AStarSolver.GetFractured(this, container, obstacles); EdgeList.Clear(); foreach (var node in fracturedPath) { EdgeList.Add(new Edge(node.Position)); } var nestedEnvironments = new List <Environment>(NestedEnvironments); foreach (var nestedEnvironment in NestedEnvironments) { nestedEnvironments.Remove(nestedEnvironment); nestedEnvironment.Fracture(this, nestedEnvironments); nestedEnvironments.Add(nestedEnvironment); } }
public void Clear() { VertexList.Clear(); EdgeSolution.Clear(); EdgeList.Clear(); }
/// <summary> /// overrides the <see cref="Solid.Refresh()"/> method. /// </summary> public override void Refresh() { VertexList.Clear(); EdgeList.Clear(); FaceList.Clear(); EdgeCurveList.Clear(); Vertex3d A = new Vertex3d(xyz.Null); Vertex3d B = new Vertex3d(new xyz(Size.x, 0, 0)); Vertex3d C = new Vertex3d(new xyz(Size.x, Size.y, 0)); Vertex3d D = new Vertex3d(new xyz(0, Size.y, 0)); Vertex3d E = new Vertex3d(A.Value + new xyz(0, 0, Size.z)); Vertex3d F = new Vertex3d(B.Value + new xyz(0, 0, Size.z)); Vertex3d G = new Vertex3d(C.Value + new xyz(0, 0, Size.z)); Vertex3d H = new Vertex3d(D.Value + new xyz(0, 0, Size.z)); VertexList.Add(A); VertexList.Add(B); VertexList.Add(C); VertexList.Add(D); VertexList.Add(E); VertexList.Add(F); VertexList.Add(G); VertexList.Add(H); Vertex3dArray_2 Border = new Vertex3dArray_2(); Vertex3dArray VA = new Vertex3dArray(); Border.Add(VA); Face Face = null; VA.Clear(); VA.Add(A); VA.Add(B); VA.Add(C); VA.Add(D); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(A); VA.Add(E); VA.Add(F); VA.Add(B); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(B); VA.Add(F); VA.Add(G); VA.Add(C); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(C); VA.Add(G); VA.Add(H); VA.Add(D); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(D); VA.Add(H); VA.Add(E); VA.Add(A); Face = Face.SolidPlane(this, Border); // FaceList.Add(Face); VA.Clear(); VA.Add(H); VA.Add(G); VA.Add(F); VA.Add(E); Face = Face.SolidPlane(this, Border); //for (int i = 0; i < FaceList.Count; i++) //{ // FaceList[i].DrawRelativToSurfaceBase = false; // FaceList[i].Refresh(); //} }
public void Clear() { EdgeList.Clear(); NodeList.Clear(); }