commit
ae17173f90
|
@ -29,11 +29,13 @@ public class Graph {
|
||||||
stack.push(start);
|
stack.push(start);
|
||||||
while (!stack.isEmpty()) {
|
while (!stack.isEmpty()) {
|
||||||
int current = stack.pop();
|
int current = stack.pop();
|
||||||
isVisited[current] = true;
|
if(!isVisited[current]){
|
||||||
visit(current);
|
isVisited[current] = true;
|
||||||
for (int dest : adjVertices.get(current)) {
|
visit(current);
|
||||||
if (!isVisited[dest])
|
for (int dest : adjVertices.get(current)) {
|
||||||
stack.push(dest);
|
if (!isVisited[dest])
|
||||||
|
stack.push(dest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue