<awangdev>261. Graph Valid Tree_2.java
private boolean dfs(Map<Integer, Set<Integer>> graph, Set<Integer> visited, int curr, int pre) {

        if (visited.contains(curr)) return false;
        visited.add(curr);
        for (int child : graph.get(curr)) {
            if (child == pre) continue;
            if (!dfs(graph, visited, child, curr)) return false;
        }
        return true;
    }
private boolean sample_funcname ( Map < Integer , Set < Integer >> graph , Set < Integer > visited , int curr , int pre ) {
  if ( visited . contains ( curr ) ) return false ;
  visited . add ( curr ) ;
  for ( int child : graph . get ( curr ) ) {
    if ( child == pre ) continue ;
    if ( ! dfs ( graph , visited , child , curr ) ) return false ;
  }
  return true ;
}
