Skip to content

Commit 528b0c0

Browse files
committed
fix dfs/exploration
1 parent 1b928eb commit 528b0c0

File tree

1 file changed

+4
-3
lines changed
  • algorithm/graph_search/dfs/exploration

1 file changed

+4
-3
lines changed

algorithm/graph_search/dfs/exploration/code.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ function DFSExplore(graph, source) {
3333
}
3434

3535
var visited = DFSExplore(G, 0);
36-
if (G.length === Object.keys(visited).length) {
36+
var check = true;
37+
for (var i = 0; i < visited.length; i++) check &= visited[i];
38+
if (check) {
3739
logger._print('The Graph is CONNECTED');
38-
}
39-
else {
40+
} else {
4041
logger._print('The Graph is NOT CONNECTED');
4142
}

0 commit comments

Comments
 (0)