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

    }