DFS max limit check change.
This commit is contained in:
parent
74f5d25dbc
commit
5ffea1aa08
@ -71,7 +71,7 @@ public class DepthFirstSearch {
|
||||
Node begin = startNode;
|
||||
queue.add(begin);
|
||||
while (!queue.isEmpty()) {
|
||||
if (maxNodesSearched != -1 && checkedNodes.size() >= maxNodesSearched) return false;
|
||||
if (maxNodesSearched != -1 && checkedNodes.size() > maxNodesSearched) return false;
|
||||
Node n = queue.poll();
|
||||
if (!n.equals(endNode)) {
|
||||
n.child[0] = new Node(n, n.x + 1, n.y);
|
||||
@ -113,7 +113,7 @@ public class DepthFirstSearch {
|
||||
queue.add(begin);
|
||||
while (!queue.isEmpty()) {
|
||||
Node n = queue.poll();
|
||||
if (maxNodesSearched != -1 && checkedNodes.size() >= maxNodesSearched) return false;
|
||||
if (maxNodesSearched != -1 && checkedNodes.size() > maxNodesSearched) return false;
|
||||
if (!targetValidator.isCoordinateTarget(n.x, n.y)) {
|
||||
n.child[0] = new Node(n, n.x + 1, n.y);
|
||||
n.child[1] = new Node(n, n.x - 1, n.y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user