this.queueInserter = queueInserter;
}
public Path search(INode start) {
List<Path> queue = new ArrayList<Path>();
queue.add(new Path(null, new Edge(start, 0)));
while (true) {
if (queue.isEmpty())
return null;
Path bestPath = queue.remove(0);
INode currentNode = bestPath.getLastEdge().getTargetNode();
if (goalTest.isGoal(currentNode))
return bestPath;
List<Path> newPaths = new ArrayList<Path>();
for (Edge edge : currentNode.generateSuccessors()) {
if (bestPath.containsNode(edge.getTargetNode()))
continue;
newPaths.add(new Path(bestPath, edge));
}
queueInserter.insert(queue, newPaths);
}
}