public void dfs(UndirectedNode root) {
        Stack<UndirectedNode> stack = new Stack<UndirectedNode>();
        stack.push(root);
        root.visited = true;
        while (!stack.isEmpty()) {
            UndirectedNode node = stack.pop();
            for (UndirectedNode nodes : node.edgeNodes) {
                if (!nodes.visited) {
                    System.out.println(nodes.data);
                    nodes.visited = true;
                    dfs(nodes);
                    stack.push(nodes);
                }
            }
        }

    }