/// <summary> /// Adds a new edge /// </summary> /// <param name="u">source vertex</param> /// <param name="v">target edge</param> /// <returns>added edge</returns> /// <exception cref="ArgumentNullException">u or v is a null reference</exception> public virtual IEdge AddEdge(IVertex u, IVertex v) { if (u == null) { throw new ArgumentNullException("u"); } if (v == null) { throw new ArgumentNullException("v"); } // check if u,v in vertex set if (!ContainsVertex(u)) { throw new ArgumentException("graph does not contain u"); } if (!ContainsVertex(v)) { throw new ArgumentException("graph does not contain v"); } // add edge if (Parent != null) { IEdge e = Parent.AddEdge(u, v); Wrapped.AddEdge(e); return(e); } else { return(Wrapped.AddEdge(u, v)); } }
/// <summary> /// Adds an existing edge to the cluster /// </summary> /// <param name="e">edge to add</param> public virtual void AddEdge(IEdge e) { if (e == null) { throw new ArgumentNullException("e"); } if (Parent != null && !Parent.ContainsEdge(e)) { Parent.AddEdge(e); } Wrapped.AddEdge(e); }