/// <summary>
 /// Adds an element with the specified key and value to this VertexVector2DDictionary.
 /// </summary>
 /// <param name="key">
 /// The IVertex key of the element to add.
 /// </param>
 /// <param name="value">
 /// The Vector2D value of the element to add.
 /// </param>
 public void Add(IVertex key, Vector2D value)
 {
     this.Dictionary.Add(key, value);
 }
 /// <summary>
 /// Determines whether this VertexVector2DDictionary contains a specific value.
 /// </summary>
 /// <param name="value">
 /// The Vector2D value to locate in this VertexVector2DDictionary.
 /// </param>
 /// <returns>
 /// true if this VertexVector2DDictionary contains an element with the specified value;
 /// otherwise, false.
 /// </returns>
 public bool ContainsValue(Vector2D value)
 {
     foreach (Vector2D item in this.Dictionary.Values)
     {
         if (item == value)
             return true;
     }
     return false;
 }
        protected void CalculateRepulsiveForces()
        {
            foreach (IVertex v in graph.Vertices)
            {
                disp[v] = new Vector2D();

                foreach (IVertex u in graph.Vertices)
                {
                    if (u != v)
                    {
                        Vector2D delta = (Vector2D)pos[v] - (Vector2D)pos[u];
                        while (delta.Norm() == 0)
                        {
                            //The vertices are occupying the same location, so randomly repel
                            Random random = new Random();
                            delta = new Vector2D(
                                random.NextDouble() * 2 - 1,
                                random.NextDouble() * 2 - 1
                                );
                        }

                        disp[v] += delta / delta.Norm() * RepulsiveForce(delta.Norm());
                    }
                }
            }
        }
 protected void CalculateRepulsiveForces()
 {
     IVertexEnumerator enumerator = this.graph.get_Vertices().GetEnumerator();
     while (enumerator.MoveNext())
     {
         IVertex vertex = enumerator.get_Current();
         Vector2D vectord2 = new Vector2D();
         this.disp.set_Item(vertex, vectord2);
         IVertexEnumerator enumerator2 = this.graph.get_Vertices().GetEnumerator();
         while (enumerator2.MoveNext())
         {
             IVertex vertex2 = enumerator2.get_Current();
             if (vertex2 != vertex)
             {
                 VertexVector2DDictionary dictionary;
                 IVertex vertex3;
                 Vector2D vectord = (Vector2D) (this.pos.get_Item(vertex) - this.pos.get_Item(vertex2));
                 while (vectord.Norm() == 0.0)
                 {
                     Random random = new Random();
                     vectord = new Vector2D((random.NextDouble() * 2.0) - 1.0, (random.NextDouble() * 2.0) - 1.0);
                 }
                 (dictionary = this.disp).set_Item(vertex3 = vertex, dictionary.get_Item(vertex3) + ((Vector2D) ((vectord / vectord.Norm()) * this.RepulsiveForce(vectord.Norm()))));
             }
         }
     }
 }
 /// <summary>
 /// Adds an element with the specified key and value to this VertexVector2DDictionary.
 /// </summary>
 /// <param name="key">
 /// The IVertex key of the element to add.
 /// </param>
 /// <param name="value">
 /// The Vector2D value of the element to add.
 /// </param>
 public void Add(IVertex key, Vector2D value)
 {
     this.Dictionary.Add(key, value);
 }