public IEnumerable<Neighbour> GetNeighbours(int nodeId)
{
var node = AbstractGraph.GetNode(nodeId);
var edges = node.Edges;
var result = new List<Neighbour>(edges.Count);
foreach (var edge in edges)
{
var edgeInfo = edge.Info;
if (edgeInfo.IsInterEdge)
{
// If the node is an interCluster edge and the edge is of a lower level than
// the current level, we have to ignore it
// This means we can use higher level interEdges.
if (edgeInfo.Level < this.currentLevel) continue;
}
else
{
// If it is NOT an interCluster edge (local edge for example) but that edge belongs to another level... ignore it
if (edgeInfo.Level != this.currentLevel) continue;
}
var targetNodeId = edge.TargetNodeId;
var targetNodeInfo = AbstractGraph.GetNodeInfo(targetNodeId);
// NOTE: Sure this if happens? Previous validations should ensure that the edge is connected to
// a node of the same level. Also... why are we checking if the target node is in the current Cluster?
// We should be able to navigate to that edge!
if (targetNodeInfo.Level < this.currentLevel || !this.PositionInCurrentCluster(targetNodeInfo.Position))
continue;
result.Add(new Neighbour(targetNodeId, edgeInfo.Cost));
}
return result;
}