/// <summary> /// Remove the edge (u,v) from the graph. /// If the graph allows parallel edges this remove all occurrences of /// (u,v). /// </summary> /// <param name="u">source vertex</param> /// <param name="v">target vertex</param> public virtual void RemoveEdge(Vertex u, Vertex v) { if (u == null) throw new ArgumentNullException("u"); if (v == null) throw new ArgumentNullException("v"); this.version++; // getting out-edges EdgeCollection outEdges = this.vertexOutEdges[u]; // marking edges to remove EdgeCollection removedEdges = new EdgeCollection(); foreach(Edge e in outEdges) { if (e.Target == v) removedEdges.Add(e); } //removing out-edges foreach(Edge e in removedEdges) outEdges.Remove(e); removedEdges.Clear(); EdgeCollection inEdges = this.vertexInEdges[v]; foreach(Edge e in inEdges) { if (e.Source == u) removedEdges.Add(e); } //removing in-edges foreach(Edge e in removedEdges) inEdges.Remove(e); }