searchStep method
Implementation
@override
void searchStep(GraphBFSState state) {
// If there is no open open node, we are stuck.
if (state.open.isEmpty) {
state.status = Status.failure;
return;
}
ID pointId = state.open.removeFirst();
state.nodes[pointId] = GraphNode.closed;
// We can return because the target is reached.
if (state.nodes[state.targetId] == GraphNode.closed) {
state.status = Status.success;
return;
}
for (ID newId in state.edges[pointId] ?? []) {
GraphNode newNode = state.getNode(newId);
if (newNode == GraphNode.closed) continue;
if (newNode != GraphNode.open) {
state.parents[newId] = pointId;
state.open.add(newId);
state.nodes[newId] = GraphNode.open;
}
}
}