コード例 #1
0
ファイル: AdjacencyGraph.cs プロジェクト: wsgan001/asegrp
 /// <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);
 }
コード例 #2
0
ファイル: AdjacencyGraph.cs プロジェクト: wsgan001/asegrp
        /// <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);
            }
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <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);
        }