I am writing a code to run DFS on a graph however these graphs are huge. I am getting a stack overflow error on DFS visit however other people were able to run DFS visit without any problems. Is there any reason why I would be getting a StackOverFlow error? I tried allocating more memory (I have 16gb RAM) however it caps me at 1gb ram.
public void DFSVisit(Graph <String, String> graph, String current, int [] data, StackObject [] finish, boolean complicated){
//data stores the time
data[9]++;
graph.setAnnotation(current, "time", data[9]);
graph.setAnnotation(current, "color", "gray");
Iterator <ArrayList<String>> itr = graph.outAdjacentVertices(current);
ArrayList <String> currentlist = null;
String adjacent;
while(itr.hasNext()){
currentlist = itr.next();
adjacent = currentlist.get(1);
if(graph.getAnnotation(adjacent, "color").equals("white")){
graph.setAnnotation(adjacent, "parent", current);
DFSVisit(graph, adjacent, data, finish, complicated);
}
}
graph.setAnnotation(current, "color", "black");
data[9]++;
graph.setAnnotation(current, "done", data[9]);
finish[0].done.push(current);
//System.out.println(current);
}