DFS max limit check change.

This commit is contained in:
Harrison Deng 2020-04-23 11:51:54 -05:00
parent 74f5d25dbc
commit 5ffea1aa08

View File

@ -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);