public virtual bool RemoveVertex(TVertex v)
        {
            if (!this.ContainsVertex(v))
            {
                return(false);
            }

            // collect edges to remove
            var edgesToRemove = new EdgeList <TVertex, TEdge>();

            foreach (var outEdge in this.OutEdges(v))
            {
                this.vertexInEdges[outEdge.Target].Remove(outEdge);
                edgesToRemove.Add(outEdge);
            }
            foreach (var inEdge in this.InEdges(v))
            {
                // might already have been removed
                if (this.vertexOutEdges[inEdge.Source].Remove(inEdge))
                {
                    edgesToRemove.Add(inEdge);
                }
            }

            // notify users
            if (this.EdgeRemoved != null)
            {
                foreach (TEdge edge in edgesToRemove)
                {
                    this.OnEdgeRemoved(edge);
                }
            }

            this.vertexOutEdges.Remove(v);
            this.vertexInEdges.Remove(v);
            this.edgeCount -= edgesToRemove.Count;
            this.OnVertexRemoved(v);

            return(true);
        }
        public virtual bool RemoveVertex(TVertex v)
        {
            if (!ContainsVertex(v))
            {
                return(false);
            }

            // collect edges to remove
            var edgesToRemove = new EdgeList <TVertex, TEdge>();

            foreach (var outEdge in OutEdges(v))
            {
                vertexInEdges[outEdge.Target].Remove(outEdge);
                edgesToRemove.Add(outEdge);
            }
            foreach (var inEdge in InEdges(v))
            {
                if (vertexOutEdges[inEdge.Source].Remove(inEdge))
                {
                    edgesToRemove.Add(inEdge);
                }
            }

            // notify users
            if (EdgeRemoved != null)
            {
                foreach (var edge in edgesToRemove)
                {
                    OnEdgeRemoved(edge);
                }
            }

            vertexOutEdges.Remove(v);
            vertexInEdges.Remove(v);
            EdgeCount -= edgesToRemove.Count;
            OnVertexRemoved(v);

            return(true);
        }
 public EdgeList(EdgeList <TVertex, TEdge> list)
     : base(list)
 {
 }