boolean isCycle(int vertex, Map<Integer, List<Integer>> graph, int parent, boolean[] visited) {
        if (visited[vertex]) {
            return true;
        }
        visited[vertex] = true;
        if (graph.get(vertex) == null) {
            return false;
        }
        for (int i : graph.get(vertex)) {
            if (i == parent) {
                continue;
            }
            if (isCycle(i, graph, vertex, visited)) {
                return true;
            }
        }
        return false;
    }
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes),
write a function to check whether these edges make up a valid tree.
https://leetcode.com/problems/graph-valid-tree/
src/com/interview/graph/ValidTree.java