コード例 #1
0
        /// <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(DataTableVertex u, DataTableVertex v)
        {
            if (u == null)
                throw new ArgumentNullException("u");
            if (v == null)
                throw new ArgumentNullException("v");

            this.version++;
            // getting out-edges
            DataRelationEdgeCollection outEdges = this.vertexOutEdges[u];

            // marking edges to remove
            DataRelationEdgeCollection removedEdges = new DataRelationEdgeCollection();
            foreach(DataRelationEdge e in outEdges)
            {
                if (e.Target == v)
                    removedEdges.Add(e);
            }
            //removing out-edges
            foreach(DataRelationEdge e in removedEdges)
                outEdges.Remove(e);

            removedEdges.Clear();
            DataRelationEdgeCollection inEdges = this.vertexInEdges[v];
            foreach(DataRelationEdge e in inEdges)
            {
                if (e.Source == u)
                    removedEdges.Add(e);
            }
            //removing in-edges
            foreach(DataRelationEdge e in removedEdges)
                inEdges.Remove(e);
        }