Esempio n. 1
0
 /// <summary>
 /// Tests if a edge is part of the graph
 /// </summary>
 /// <param name="e">Edge to test</param>
 /// <returns>true if is part of the graph, false otherwize</returns>
 public bool ContainsEdge(IEdge e)
 {
     foreach (DictionaryEntry di in VertexOutEdges)
     {
         EdgeCollection es = (EdgeCollection)di.Value;
         if (es.Contains(e))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 2
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);
        }
Esempio n. 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 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);
        }
Esempio n. 4
0
        int[,] CreateMatrix()
        {
            int[,] array = new int[this.Controls.Count - 1, this.Controls.Count - 1];

            for (int i = 0; i < array.GetLength(0); i++)
            {
                for (int j = 0; j < array.GetLength(0); j++)
                {
                    if (_edges.Contains(new Edge(i + 1, j + 1), this.IsUndirectedGraph))
                    {
                        array[i, j] = GetDistance(this.Controls[i + 1].Location, this.Controls[j + 1].Location);
                    }
                    else if (i != j)
                    {
                        array[i, j] = -1;
                    }
                }
            }
            return(array);
        }
Esempio n. 5
0
 /// <summary>
 /// Tests if a edge is part of the graph
 /// </summary>
 /// <param name="v">Edge to test</param>
 /// <returns>true if is part of the graph, false otherwize</returns>
 public bool ContainsEdge(IEdge v)
 {
     return(m_Edges.Contains(v));
 }