コード例 #1
0
        /// <summary>
        /// Creates a new vertex.
        /// </summary>
        /// <param name="name">The name of the vertex.</param>
        /// <param name="x">The X-location of the vertex.</param>
        /// <param name="y">The Y-location of the vertex.</param>
        public void CreateVertex(char name, int x, int y)
        {
            DijkstraVertexLabel v = new DijkstraVertexLabel(name, new Point(x, y));

            v.SetReadOnly(true);
            v.BackColor = Color.White;
            this.vertices.Add(v);
            this.panel.Controls.Add(v);
            mapMatrix.EnableVertex(v.GetNumberIndex());
        }
コード例 #2
0
 /// <summary>
 /// Gets the distance between this label and another vertex label.
 /// </summary>
 /// <param name="v">The other vertex label.</param>
 /// <returns>The distance between the two labels.</returns>
 public double GetDistance(DijkstraVertexLabel v)
 {
     return(Math.Sqrt((v.GetCentreLocation().X - this.GetCentreLocation().X) * (v.GetCentreLocation().X - this.GetCentreLocation().X)
                      + (v.GetCentreLocation().Y - this.GetCentreLocation().Y) * (v.GetCentreLocation().Y - this.GetCentreLocation().Y)));
 }