function dfs(graph, node, visited) {
    if (visited[node]) return null; // node is already visited, get out of here.
    var subGraph = [];
    visited[node] = true;
    subGraph.push(node);
    for (var i in graph[node]) {
        var result = dfs(graph, i, visited);
        if (result == null) continue;
        subGraph = subGraph.concat(result);
    }
    return subGraph;
}
// it will return an array of all connected nodes in a subgraph
it will return an array of all connected nodes in a subgraph
it will return an array of all connected nodes in a subgraph
function dfs(graph, node, visited) {
    if (visited[node]) return null; 
    var subGraph = [];
    visited[node] = true;
    subGraph.push(node);
    for (var i in graph[node]) {
        var result = dfs(graph, i, visited);
        if (result == null) continue;
        subGraph = subGraph.concat(result);
    }
    return subGraph;
}
function dfs ( graph , node , visited ) { if ( visited [ node ] ) return null ; var subGraph = [ ] ; visited [ node ] = true ; subGraph . push ( node ) ; for ( var i in graph [ node ] ) { var result = dfs ( graph , i , visited ) ; if ( result == null ) continue ; subGraph = subGraph . concat ( result ) ; } return subGraph ; }
it will return an array of all connected nodes in a subgraph
it will return an array of all connected nodes in a subgraph
// node is already visited, get out of here.