示例#1
0
        /// <summary>
        /// Creates an edge between this node and another node.
        /// Its cost is set to the distance between their screen positions.
        /// </summary>
        public void AddEdge(Node neighbor)
        {
            double         cost = Math.Sqrt(Square(Position.X - neighbor.Position.X) + Square(Position.Y - neighbor.Position.Y));
            UndirectedEdge e    = new UndirectedEdge(this, neighbor, cost);

            Edges.Add(e);
            neighbor.Edges.Add(e);
        }
示例#2
0
        private bool EdgeOnPath(UndirectedEdge edge)
        {
            if (highlightedPath == null || highlightedPath.Count == 0)
            {
                return(false);
            }
            int i = highlightedPath.IndexOf(edge.A);

            if (i < 0)
            {
                return(false);
            }
            return(highlightedPath[Math.Max(i - 1, 0)] == edge.B ||
                   highlightedPath[Math.Min(i + 1, highlightedPath.Count - 1)] == edge.B);
        }