コード例 #1
0
        public static Node NearestUnvisitedNodeToTarget(this CalculateShortestPath.MapRole map)
        {
            var context = Context.Current <CalculateShortestPath>(map, c => c.Map);

            var  min      = ManhattanGeometry.Infinity;
            Node selected = null;

            foreach (var node in context.Unvisited)
            {
                var distance = node.TentativeDistance();
                if (distance >= min)
                {
                    continue;
                }

                selected = node;
                min      = distance;
            }

            return(selected);
        }
コード例 #2
0
 public static Node NextDownTheStreetFrom(this CalculateShortestPath.MapRole map, Node x)
 {
     return(map.EastNeighborOf[x]);
 }
コード例 #3
0
 public static Node NextAlongTheAvenueFrom(this CalculateShortestPath.MapRole map, Node x)
 {
     return(map.SouthNeighborOf[x]);
 }
コード例 #4
0
 public static int DistanceBetween(this CalculateShortestPath.MapRole map, Node a, Node b)
 {
     return(map.Distances[new Edge(a, b)]);
 }