I am currently working on optimizing my code. In order to do that, I have to make sure that my sequential BFS works perfectly. Then, I should I apply threads or executor service to run it in parallel. Will my BFS break if the graph is too big?public void bfs(int rootNode, isvisited visitor){// BFS uses Queue data structureQueue<Integer> q = new LinkedList<Integer>();int currentLevel = 0;q.add(rootNode);visitor.visit(rootNode, currentLevel);while (!q.isEmpty()){    currentLevel++;    Set<Integer> nextNodes = new LinkedHashSet<Integer>();    q.forEach(currNode ->nextNodes.addAll(outgoingNeighbors(currNode)));    q.clear();    for (int child : nextNodes)     {        visitor.visit(child, currentLevel);        q.add(child);    }} }
Java sequential BFS
java;graph;breadth first search;visitor pattern