Beispiel #1
0
 public Edge(Node startNode, Node endNode)
 {
     this.Start = startNode;
     this.End = endNode;
     this.Length = this.Start.DistanceTo(this.End);
     this.Id = GetNextId();
 }
Beispiel #2
0
 /// <summary>
 /// Calculates the distance to another node
 /// </summary>
 /// <param name="other">The other node</param>
 /// <returns>the distance</returns>
 public double DistanceTo(Node other)
 {
     return DistanceBetween(this, other);
 }
Beispiel #3
0
 public static double SquaredDistanceBetween(Node n1, Node n2)
 {
     return (n1.X - n2.X) * (n1.X - n2.X) + (n1.Y - n2.Y) * (n1.Y - n2.Y);
 }
Beispiel #4
0
 /// <summary>
 /// Calculates the distance between two nodes
 /// </summary>
 /// <param name="n1">The first node</param>
 /// <param name="n2">The second node</param>
 /// <returns>the distance</returns>
 public static double DistanceBetween(Node n1, Node n2)
 {
     return Math.Sqrt(SquaredDistanceBetween(n1, n2));
 }
Beispiel #5
0
 public double SquaredDistanceTo(Node other)
 {
     return SquaredDistanceBetween(this, other);
 }
 private void OnNodeAdded(Node node)
 {
     if (this.Max_x < node.X)
     {
         this.Max_x = node.X;
     }
     if (this.Max_y < node.Y)
     {
         this.Max_y = node.Y;
     }
     this.Nodes.Add(node);
     //this.RaiseDataChanged();
 }
 private void Graph_NodeAdded(Node node)
 {
     this.dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate() { this.OnNodeAdded(node); }));
 }
 public void AddNode(Node node)
 {
     this.Nodes.Add(node);
     this.Path.Add(node);
     this.RaiseNodeAdded(node);
 }
 private void RaiseNodeAdded(Node node)
 {
     if (this.NodeAdded != null)
     {
         this.NodeAdded(node);
     }
 }
Beispiel #10
0
 // swap the start and end nodes of the edge
 public void ReverseDirection()
 {
     Node temp = this.Start;
     this.Start = this.End;
     this.End = temp;
 }
 /// <summary>
 /// Calculates the distance between two nodes
 /// </summary>
 /// <param name="n1">The first node</param>
 /// <param name="n2">The second node</param>
 /// <returns>the distance</returns>
 public static double DistanceBetween(Node n1, Node n2)
 {
     return Math.Sqrt((n1.X - n2.X) * (n1.X - n2.X) + (n1.Y - n2.Y) * (n1.Y - n2.Y));
 }
 public void DrawNode(Node node)
 {
     this.DrawEllipse(node.X, node.Y);
 }