/// <summary> /// Removes an edge from the graph. /// /// Complexity: 2 edges removed from the vertex edge list + 1 edge /// removed from the edge list. /// </summary> /// <param name="e">edge to remove</param> /// <exception cref="ArgumentNullException">e is null</exception> public virtual void RemoveEdge(IEdge e) { if (e == null) { throw new ArgumentNullException("edge"); } // removing edge from vertices VertexOutEdges[e.Source].Remove(e); m_Edges.Remove(e); }
/// <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(IVertex u, IVertex v) { if (u == null) { throw new ArgumentNullException("source vertex"); } if (v == null) { throw new ArgumentNullException("targetvertex"); } EdgeCollection edges = VertexOutEdges[u]; // marking edges to remove EdgeCollection removedEdges = new EdgeCollection(); foreach (IEdge e in edges) { if (e.Target == v) { removedEdges.Add(e); } } //removing edges foreach (IEdge e in removedEdges) { edges.Remove(e); m_Edges.Remove(e); } }
/// <summary> /// Removes an edge from the graph. /// /// Complexity: 2 edges removed from the vertex edge list + 1 edge /// removed from the edge list. /// </summary> /// <param name="e">edge to remove</param> /// <exception cref="ArgumentNullException">e is null</exception> public virtual void RemoveEdge(IEdge e) { if (e == null) { throw new ArgumentNullException("edge"); } // removing edge from vertices EdgeCollection outEdges = VertexOutEdges[e.Source]; if (outEdges == null || !outEdges.Contains(e)) { throw new EdgeNotFoundException(); } outEdges.Remove(e); }
/// <summary> /// Removes an edge from the graph. /// /// Complexity: 2 edges removed from the vertex edge list + 1 edge /// removed from the edge list. /// </summary> /// <param name="e">edge to remove</param> /// <exception cref="ArgumentNullException">e is null</exception> public override void RemoveEdge(IEdge e) { if (e == null) { throw new ArgumentNullException("edge"); } base.RemoveEdge(e); EdgeCollection inEdges = VertexInEdges[e.Target]; if (inEdges == null || !inEdges.Contains(e)) { throw new EdgeNotFoundException(); } inEdges.Remove(e); }