public int dfs(Map<Integer, List<Integer>> graph, int start, Set<Integer> visited) {
    visited.add(start);
    if (graph.containsKey(start)) {
      int max = 0;
      for (int child : graph.get(start)) {
        if (!visited.contains(child)) {
          max = Math.max(max, dfs(graph, child, visited));
        }
      }
      return max + 1;
    } else {
      return 1;
    }
  }