Пример #1
0
 /// <summary>
 /// Add a point to the edge
 /// </summary>
 /// <param name="vertex">Vertex</param>
 /// <param name="index">Index of the closest point</param>
 public void AddPoint(Vertex vertex, int index)
 {
     if (index == 0)
         P1 = vertex;
     else if (index == Track.TrackSegments.First().WayPoints.Count - 1)
         P2 = vertex;
     else // this is used to figure out where to split a track into 2
         throw new Exception(string.Format("Need to split track at {0}", index));
 }
Пример #2
0
 /// <summary>
 /// Retrieve the distance between the two nodes as calculated by the Floyd-Warshall algorithm.
 /// </summary>
 /// <param name="p1">Vertex 1</param>
 /// <param name="p2">Vertex 2</param>
 /// <returns>Distance in km</returns>
 public double Distance(Vertex p1, Vertex p2)
 {
     return dist[p1.Index, p2.Index];
 }
Пример #3
0
 /// <summary>
 /// Find a shortest path from p1 to p2 using the results of the Floyd-Warshall algorithm.
 /// </summary>
 /// <param name="p1">point 1</param>
 /// <param name="p2">point 2</param>
 /// <returns>A list of the vertices on a shortest path from p1 to p2</returns>
 public List<Vertex> Path(Vertex p1, Vertex p2)
 {
     return Path(idx: p1.Index, jdx: p2.Index);
 }
Пример #4
0
 /// <summary>
 /// Constructor using two vertices
 /// </summary>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 public Edge(Vertex v1, Vertex v2)
 {
     Weight = v1.Point.GetDistanceFrom(v2.Point);
     P1 = v1;
     P2 = v2;
 }
Пример #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="track">track</param>
 /// <param name="point">point</param>
 public ConnectInfo(Edge track, Vertex point, int idx, double dist)
 {
     this.track = track;
     this.point = point;
     this.index = idx;
     this.dist = dist;
 }