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