{"size": 429, "ext": "js", "max_stars_repo_path": "javascript/challenges/graphs/dfs.js", "max_stars_repo_name": "tiggerman120/dataStructuresAndAlgorithms", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "javascript/challenges/graphs/dfs.js", "max_issues_repo_name": "tiggerman120/dataStructuresAndAlgorithms", "max_issues_repo_issues_event_min_datetime": "2020-12-08T00:35:24.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-28T22:59:10.000Z", "max_forks_repo_path": "javascript/challenges/graphs/dfs.js", "max_forks_repo_name": "tiggerman120/dataStructuresAndAlgorithms", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 21.45, "max_line_length": 46, "alphanum_fraction": 0.6526806527}
'use strict';

function dfs(startNode) {
  //add node to set
  const visitedNodes = new Set();
  const traverseNeighbors = (node) => {
    visitedNodes.add(node);
    const neighbors = this.getNeighbors(node);
    for (const edge of neighbors) {
      if (!visitedNodes.has(edge.vertex)) {
        traverseNeighbors(edge.vertex);
      }
    }
  };
  traverseNeighbors(startNode);
  return visitedNodes;
}

module.exports = dfs;
