public static Node EastNeighbor(this CalculateShortestPath.CurrentIntersectionRole currentIntersection) { var c = Context.Current <CalculateShortestPath>(currentIntersection, ct => ct.CurrentIntersection); var neighborOf = c.Map.EastNeighborOf; return(neighborOf.ContainsKey((Node)c.Current) ? neighborOf[(Node)c.Current] : null); }
public static IList <Node> UnvisitedNeighbors(this CalculateShortestPath.CurrentIntersectionRole currentIntersection) { var context = Context.Current <CalculateShortestPath>(currentIntersection, c => c.CurrentIntersection); var output = new List <Node>(); var unvisited = context.Unvisited; var south = currentIntersection.SouthNeighbor(); var east = currentIntersection.EastNeighbor(); if (south != null && unvisited.Contains(south)) { output.Add(south); } if (east != null && unvisited.Contains(east)) { output.Add(east); } return(output); }